[thechat] determining most recent midnight

William Anderson neuro at well.com
Thu Feb 20 21:56:02 CST 2003


gozz  wrote:
> Was going to post this to the list, but solved my problem
> by converting to a string date w/o the time and then
> parsing that back into a unix epoch time ... but ... I can't
> figure out what's wrong with the way I was trying to
> mathematically figure out when the most recent midnight
> was:
>
> $unix_time = seconds since Jan 1, 1970;
> $seconds_in_day = 60 * 60 * 24;
> $seconds_since_most_recent_midnight = $unix_time %
> $seconds_in_day;
> $most_recent_midnight = $unix_time -
> $seconds_since_most_recent_midnight;
>
> Where do I go wrong there?

dunno, cos it looks fine here.

$secondsSinceMidnight = time() % 86400;

is probably shorter tho.  this probably belongs on thelist tho.


--
_ __/|   ___  ___ __ _________ "When Microsoft Office is your only hammer,
\`O_o'  / _ \/ -_) // / __/ _ \ pretty much everything begins to look like
=(_ _)=/_//_/\__/\_,_/_/  \___/ a nail. Or a thumb." -- Rob Pegoraro
   U - Ack! Phttpt! Thhbbt!     neuro at well dot com  http://neuro.me.uk/



More information about the thechat mailing list