Most people who take magnesium for sleep take it in the evening, roughly 30 to 60 minutes before bed. There's no single correct minute. What helps more is taking it at about the same time each night so it becomes automatic.
Why evening is the common choice
Some people find magnesium helps them feel more relaxed before bed, so evening is the natural slot. Taking it 30 to 60 minutes before you turn in gives it a little time to settle before you're trying to fall asleep, which is why that window comes up so often.
Don't get hung up on the exact time, though. A routine you actually keep will do more for you than a perfect schedule you drop after a week.
If you're better at remembering supplements in the morning, that works too. Steady beats ideal. Some people split things up, with a multivitamin in the morning and magnesium at night, just because that matches how their day goes. The goal is for it to become a predictable part of your evening, not something you scramble to remember.
Making it a habit that sticks
Attach it to something you already do every night: brushing your teeth, plugging in your phone, laying out tomorrow's clothes. Pairing a new habit with an old one tends to work far better than willpower, especially on nights when you're tired and just want to get into bed.
Those tired nights are where a reminder helps. You can check it off right from the lock screen before you forget. Pillog keeps everything on your phone with no account and shows your month as a single card, so you can see at a glance how consistent you've been. Watching a habit you can't otherwise see turn into a visible record is oddly motivating.
Where you keep the bottle matters as well. If it lives in a cabinet you only open in the morning, move it. A small dish on the nightstand or next to your toothbrush can do as much for consistency as any app, and the two work fine together.
Starting gently and paying attention to how you feel
With anything new, magnesium included, many people start with a smaller amount and watch how they respond over the first week or two before going higher. That gives you time to notice changes in your sleep, your digestion, or how relaxed you feel in the evening before deciding whether to adjust.
People respond differently, so what works for a friend may not feel the same for you. If you're unsure which type or how much fits your situation, ask your doctor or pharmacist. That's especially true if you take other medicines or supplements, because timing relative to those can matter too.
A quick note of when you took it and how you slept, even just a mental one, makes patterns easier to spot than trying to remember weeks later.