Melatonin doesn’t actually stay in the body for very long. Most people eliminate all melatonin from their system within five hours of taking it, which means you should feel minimal effects if you take it before you go to sleep at night.