Nutrients

The short answer
The richest everyday sources are pumpkin seeds, almonds, spinach, dark chocolate, black beans and cashews. UK adults need around 300mg daily for men and 270mg for women. A 30g handful of pumpkin seeds provides roughly 150mg, which is over half the daily requirement in one snack.
Magnesium is involved in over 300 enzyme reactions, including muscle function, nerve signalling, blood glucose control and the production of melatonin. It also appears in roughly every wellness product on the market, which makes it hard to tell whether you actually need any.
Here is the useful version: what has it, how much you need, and who genuinely benefits from a supplement.
UK reference intakes are approximately 300mg a day for men and 270mg for women. That is reachable through food without much effort, which is worth saying given how heavily magnesium is marketed.
A handful of pumpkin seeds and a cooked portion of spinach gets most people most of the way there before anything else is counted.
Stress increases magnesium loss, and low magnesium worsens the stress response.
The loop is the reason it is worth checkingExcess magnesium from food is not a concern, because absorption self-regulates. Excess from supplements causes diarrhoea, and can be genuinely dangerous in kidney disease. Check with your GP before supplementing if your kidney function is impaired.
Keep a jar of pumpkin seeds where you can see it. Add them to porridge, salads and yoghurt, or eat them as they are. One habit covers over half the daily requirement, costs very little, and needs no decisions about forms or dosages.
Pumpkin seeds are the most efficient everyday source at around 150mg per 30g handful. Almonds, spinach, dark chocolate, black beans and cashews follow, all providing between 60mg and 80mg per typical portion.
UK reference intakes are around 300mg daily for men and 270mg for women. This is achievable through food for most people without needing a supplement.
Magnesium glycinate is generally preferred for sleep and anxiety, being well absorbed and gentle on the stomach. Citrate is well absorbed and mildly laxative. Magnesium oxide is cheap but poorly absorbed and largely passes through.
Muscle cramps, fatigue, poor sleep, and increased anxiety are commonly reported, though all have many possible causes. Blood tests are an unreliable measure, since most body magnesium is stored in bone and tissue rather than blood.
If you are taking it for sleep, evening makes sense, as magnesium supports the enzymes involved in melatonin production. Glycinate is the form usually recommended for this purpose.