php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40861 strtotime() behaviour has changed
Submitted: 2007-03-20 09:07 UTC Modified: 2007-04-11 14:37 UTC
From: eheien at heli-one dot ca Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.2.1 OS: Windows 2003 and XP
Private report: No CVE-ID: None
 [2007-03-20 09:07 UTC] eheien at heli-one dot ca
Description:
------------
strtotime() fails when supplied with both a negative and positive argument. This worked in php 5.0.5 and php 4.x.x.

+- = -
++ = +
-- = +


Reproduce code:
---------------
$offset = -60;
$ts = strtotime('2000-01-01 12:00:00');
$result = date("Y-m-d H:i:s", strtotime("+$offset minutes", $ts));
echo $result;

Expected result:
----------------
2000-01-01 11:00:00

Actual result:
--------------
1970-01-01 01:00:00

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-21 00:25 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2007-03-21 09:41 UTC] derick@php.net
Reverted that patch, as it was incorrect. 
 [2007-04-11 14:37 UTC] derick@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC