Is your sleep schedule out of whack? Instead of taking melatonin or sleeping pills, try loading up on magnesium-rich foods like chocolate, nuts, bananas, spinach and yogurt.

Researchers from the University of Edinburgh recently made a surprising discovery: magnesium, a vital mineral previously linked to healthy blood pressure, sturdy bones and strong hearts, plays a significant role in controlling our body clocks.

Researchers said the latest study, which involved experiments on human cells, algae and fungi, is important for human and plant health because it provides valuable insights into the development of chronotherapy, treatment scheduled by time of day.

After examining the levels of magnesium levels in human, algae and fungi cells, researchers found that levels of the minerals fluctuate constantly - rising and falling throughout the course of a 24-hour day.

Deeper analysis revealed that the rise and fall of magnesium levels was vital in maintaining a 24-hour cell cycle, especially when it came to cell metabolism, or how quickly cells can turn nutrients into energy. Researchers noted that the newly discovered 24-hour fluctuation cycle of magnesium concentration applied to all cell types in the study.

Study findings also revealed that the oscillation of magnesium levels controlled the biological function of when and how effectively cells burned energy.

"Internal clocks are fundamental to all living things. They influence many aspects of health and disease in our own bodies, but equally in crop plants and micro-organisms. It is now essential to find out how these fundamentally novel observations translate to whole tissue or organisms, to make us better equipped to influence them in complex organisms for future medical and agricultural purposes," said Gerben van Ooijen, of the University of Edinburgh's School of Biological Sciences, who led the study.

"Although the clinical relevance of magnesium in various tissues is beginning to garner more attention, how magnesium regulates our body's internal clock and metabolism has simply not been considered before. The new discovery could lead to a whole range of benefits spanning human health to agricultural productivity," said John O'Neill, of the MRC Laboratory of Molecular Biology in Cambridge, who co-authored the study.

The latest findings were published in the journal Nature.