Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Strange strtotime() behavior
October 10, 2004, 1:25 am
rate this thread
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 184.108.40.206, php 5.0.1, apache2
Thanks in advance.
Re: Strange strtotime() behavior
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: http://bugs.php.net/bug.php?id=29557
-- brion vibber (brion @ pobox.com)