Melatonin should be taken 1-2 hours before bed. It’s important to take it at the same time each night to help establish a regular sleep-wake cycle.