Strange strtotime() behavior

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() . &...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-10-2004
peabody
 
Posts: n/a
Default Strange strtotime() behavior

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

Reply With Quote
  #2 (permalink)  
Old 10-10-2004
Brion Vibber
 
Posts: n/a
Default Re: Strange strtotime() behavior

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)
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:36 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0