By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,958 Members | 1,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,958 IT Pros & Developers. It's quick & easy.

Strange strtotime() behavior

P: n/a
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

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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)
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.