This is a discussion on Strange strtotime() behavior within the PHP Language forums, part of the PHP Programming Forums category; I'm trying to use the strtotime() function to manage sessions. But I get the following <?php print(time() . &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I'm trying to use the strtotime() function to manage sessions. But I
get the following <?php print(time() . " - " . strtotime("+1 hour")); ?> outputs: 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 2.6.8.1, php 5.0.1, apache2 Thanks in advance. Jason |
|
|||
|
peabody wrote:
> 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. 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) |