From what I've read, you can do one 2 hours before bed (because the coffee will have you wired) and then another one the next morning.
I also heard it's better to take magnesium in pill form, because Epsom Salts can be irritating/damaging to the bowel lining. That's just what I've read though. So do your research and decide what you want.