Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- StrToTime () issue
- Pjotr Wedersteers
September 9, 2004, 4:45 pm
rate this thread
script for my pagecounter that displays hits since midnight.
I also display the number of hours and minutes passed since midnight.
$start = strtotime ('today 00:00');
$timepassed = date ('H:i', time () - $start);
The weird part is at 11.30 AM it says 12 hrs and 30 minutes have passed.
I tried adding GMT+1 like so: $start = strtotime ('today 00:00 GMT+1');
because I suspect the fact I'm in Holland is the reason for the
But this format is refused by strtotime. (-1)
Does anyone know
a) whether this is indeed the problem, and
b) how to fix it. Preferrably not alone for me here, but in suc a way anyone
around the globe would have a correctly working script if they'd use mine.
The php page for strtotime pointed me to a link at gnu.org where the syntax
for it apparantly is listed, but I get a no such page error.
Re: StrToTime () issue
Your logic is broken, you have no idea what you are actually doing :)
You are creating a date in 1970 plus some seconds.
Replace 'H:i' with 'r' and you'll see the problem. Apparently the offset
to UTC was +1 at that time, now its' +2 (DST rulez).
You should just take the 2 timestamps, subtract and calulate whatever
you want from the seconds, but even that goes wrong when timestamps are
in differente DST settings... workaround is to use gmdate where there is
not such thing...