I have the need to take the current timestamp and normalize it to an interval. I had a working example of this for 10 minute intervals, but for some reason it won't work with days.
So for example, I want to take the timestamp right now and get the timestamp of the most recent occurance of 3am was. It might be march 24th at 2am, which means that 3am hasn't hit yet so I need march 23rd's 3 am timestamp.
I tried using strtotime('3am') but it gets today's 3 am, even if that time hasn't happened yet. How can I force it to get the most recent 3 am, not just today's?
Does this make any sense at all? I not, imagine this, I've got a timestamp, 1300955926, which represents the time 3/24/11 at 2:38:46 am CST. I need the timestamp for the most recent 10 minute interval. We'll call our timestamp $now, for ease. To get the 10 minute interval, I'd do this simple math:
$now - ($now % 600);
600 being the number of seconds in a 10 minute period, I subtract the remainder of $now / 600 from $now and I get a timestamp that represents the new time, 3/24/11 at 2:30:00 am CST. For some reason though I can't get this to work for days with the same math, but mod'ing by 86400 (seconds in a day) instead.