Most melatonin supplements are designed to be taken about half an hour to an hour before bedtime. Unlike some types of sleeping pills, the effects of melatonin are gradual. Melatonin works best when paired with healthy sleep hygiene behaviors.