how long before magnesium works for sleep