Strange strtotime() behavior

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

Threaded View
I'm trying to use the strtotime() function to manage sessions.  But I
get the following

print(time() . " - " . strtotime("+1 hour"));


1097380666 - 1097308800

Strange strtotime("+1 hour") produced a time stamp less than the
current time.  It also never changes.  In other words strtotime("+1
hour") always results in the time stamp 1097308800.

I have also tried strtotime("+1 hour", time()) with the same result

Is this correct, have I misunderstood the strtotime() function?

I'm running Gentoo with kernal, php 5.0.1, apache2
Thanks in advance.


Re: Strange strtotime() behavior

peabody wrote:
Quoted text here. Click to load it

It works as expected (returns a timestamp 3600 seconds after current
time) on 4.3.8 on Mac OS X and 4.3.6 on a Fedora Core 2 Linux box I
tried, but fails just like yours does on PHP 5.0.2 on another FC2 box.

On 5.0 it seems to be using the previous midnight (local time) instead
of the current time as the base: strtotime("now") returns the previous
midnight, and strtotime("+1 hour") returns 1:00 am last night.

This bug report seems to be relevant:

-- brion vibber (brion @

Site Timeline