A cup of coffee in the evening may be keeping you awake for more reasons than you realise, scientists say.
Their study, in Science Translation Medicine, showed caffeine was more than just a stimulant and actually slowed down the body's internal clock.
A double espresso three hours before bedtime delayed the production of the sleep hormone melatonin by about 40 minutes, making it harder to nod off.
Experts said our own actions had a huge influence on sleep and the body clock.
One of the researchers, Dr John O'Neill, from the Medical Research Council's Laboratory of Molecular Biology in Cambridge, told the BBC News website: "If you're tired and having a coffee at night to stay awake, then that is a bad idea, you'll find it harder to go to sleep and get enough sleep."
In his half of the study, cells grown in a dish were exposed to caffeine to work out how it changed their ability to keep time.
It showed the drug was able to alter the chemical clocks ticking away in every cell of the human body.
Wakey wakey
Meanwhile, five people at the University of Colorado Boulder, in the US, were locked in a sleep laboratory for 50 days.
And as light exposure is the main way we normally control our body clock, they spent most of their incarceration in very dim light.
In a series of experiments over the month and a half, the scientists showed that an evening dose of caffeine slowed the body clock by 40 minutes.
It had roughly half the impact of three hours of bright light at bedtime.
Take the test - are you are lark or an owl?
Dr O'Neill said it would be "complete speculation" to set a cut-off time for drinking caffeine in the evening but he personally never drank coffee after 17:00.
He said the findings may help treat some sleep disorders and people who naturally woke up too early - known as larks - to help keep them in sync with the rest of the world.
"It could be useful with jet lag if you are flying east to west where taking caffeine at the right time of day might speed up the time it takes to overcome jet lag," he added.
Prof Derk-Jan Dijk, from the University of Surrey, told the BBC: "Individuals differ in their sensitivity to caffeine, and if coffee drinkers experience problems with falling asleep, they may try to avoid drinking coffee in the afternoon and evening."
He added that people "too often" thought they were a "slave" to their body clocks and programmed to wake up early or late.
"These and other data clearly indicate that we can to some extent modify these rhythms and that part of the reason why we sleep so late relates to factors such as caffeine intake and the exposure to artificial light in the evening," he said.