Fruit flies learned to crave sweets that came at certain times. (G. Ophir/University of California, San Francisco via AP)

Fruit flies aren't known for their stunning intelligence, but new research suggests that they can keep track of time. In a study published Thursday in Current Biology, researchers led by Martin Heisenberg of Rudolf Virchow Center in Germany used scent cues to show that even simple flies can sense time.

Previous studies have shown that mice and honeybees can be conditioned to associate certain times of day with different rewards, like food or a mate. Fruit flies are very well understood -- scientists have a great handle on how their genes are organized, so it's not hard to figure out what genetic changes cause behavioral ones -- so Heisenberg decided to see if this sense of time could be replicated in a such a simple organism.

[Hunting dragonflies can perfectly predict their prey’s future movements]

For two days in a row, Heisenberg and his colleagues exposed fruit flies to sugary treats in the morning and afternoon -- each with a specific smell. On the third day, they had access to both.

"Hungry flies learn that in the morning the odor of banana promises food and that in the afternoon the odor of apple promises food," Heisenberg said. "If this was true for two consecutive days, on the third day the flies in their choice between odor of banana and apple prefer banana in the morning and apple in the afternoon."

They're not exactly building sundials, but it's kind of mind-blowing to imagine such a tiny creature keeping any mark of their days. The effect persisted as long as the "morning" and "afternoon" conditioning sessions were at least four hours apart, and as long as the flies' circadian rhythm wasn't interrupted with constant sunlight.

Now that they know flies exhibit this time-coded behavior, Heisenberg and his colleagues can explore just what genes have created the capability, and how time functions in a fly brain. That could eventually help explain the phenomenon in other, more complex organisms. However they manage it, it's definitely an evolutionary advantage.

"Most organisms have an endogenous clock to organize their behavior over the day. This behavioral control is innate. To be able to modify this control by experience is a substantial advantage. For instance, in nature certain flowers provide food at certain times of the day, certain predators may be around at particular times, etc.," Heisenberg said.

Want more science? Give these a click:

Video reveals the incredible acrobatic feats (and occasional face plants) of a pouncing praying mantis

Bats use a super sense of touch to fly with precision

Female fruit flies prefer mates with dazzle. Dullards needn’t bother.

Mom’s first boyfriend might influence later offspring (in flies, anyway)