StrToTime () issue

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm using strtotime to get the timestamp for midnight. I have a statistics
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 where the syntax
for it apparantly is listed, but I get a no such page error.

Re: StrToTime () issue

Pjotr Wedersteers wrote:
Quoted text here. Click to load it

How about:

$start = strtotime('today 00:00') + 3600;

If the Internet is a Marx Brothers movie, and Web, e-mail, and IRC are
Groucho, Chico, and Harpo, then Usenet is Zeppo.

Re: StrToTime () issue

Quoted text here. Click to load it

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...


  Daniel Tryba

Re: StrToTime () issue

Quoted text here. Click to load it
                       ^^^^^^ should be: UTC as timezone.


  Daniel Tryba

Site Timeline