According to research reported in the Cell Press journal Current Biology today, fruit flies know what time of day it is. What’s more, the insects can learn to connect different scents with the sweet reward of sugar, depending on the hour: menthol in the morning and mushrooms in the afternoon.

Researchers say that the findings show the surprising mental abilities of animals, no matter how small.

“If even the fly, with its miniature brain, has the sense of time, most animals may have it,” says Martin Heisenberg of Rudolf Virchow Center in Germany, in a release.

In earlier studies, researchers showed that mice and honeybees can associate a reward—food or a mate, for instance—with a particular time of day. To understand how this memory for time works in the new study, Heisenberg and his colleagues looked to the fruit fly.

The researchers trained hungry flies to associated two different chemical odors with sugar in the morning or in the afternoon on two consecutive days. On the third day, they tested the flies’ preference for one scent or the other.

The results were clear: The flies learned to switch their scent preference over the course of the day. Flies tested in the morning preferred the odor paired during training with sucrose in the morning, while flies tested in the afternoon preferred the odor paired with sucrose in the afternoon. Their ability to tell time remained as long as the two separate events were separated by a period of at least four hours.

The researchers found that the flies’ time-keeping ability remained both in constant darkness and with a regular light-dark cycle. The flies couldn’t keep time, however, when the lights were kept on around the clock. Flies lacking clock genes known to be important for maintaining a daily circadian rhythm still learned to like certain odors, but they couldn’t associate those scents with the time.

The findings show that flies can use time as an additional clue to find what’s good to eat. The next step is to explore the underlying molecular mechanism for this time-odor learning in greater detail.

“Given the formidable collection of genetic tools for studying the fly brain, this can now be achieved,” Heisenberg says.