php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37368 Incorrect timestamp returned for strtotime()
Submitted: 2006-05-08 17:16 UTC Modified: 2006-08-01 22:19 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: ramsey@php.net Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.1.4 OS: Debian sarge
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ramsey@php.net
New email:
PHP Version: OS:

 

 [2006-05-08 17:16 UTC] ramsey@php.net
Description:
------------
When using strtotime() in PHP 5.1.4, it returns an inaccurate timestamp, but PHP 5.0.4 and 4.4.2 return the correct timestamp.

Reproduce code:
---------------
php -r 'echo date("r", strtotime("Mon, 08 May 2006 13:06:44 -0400 +30 days"));'

Expected result:
----------------
Wed, 07 Jun 2006 13:06:44 -0400

Actual result:
--------------
Mon, 12 Jun 2006 13:06:44 -0400

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-14 17:35 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.


 [2006-05-24 21:34 UTC] ramsey@php.net
I'm not sure whether this is related, but I found a new issue with strtotime(). It looks like the words "second" and "third" are not working correctly. 

Reproduce code:
echo date('r', strtotime('May 1st first Monday')) . "\n";
echo date('r', strtotime('May 1st second Monday')) . "\n";
echo date('r', strtotime('May 1st third Monday')) . "\n";
echo date('r', strtotime('May 1st fourth Monday')) . "\n";
echo date('r', strtotime('May 1st fifth Monday')) . "\n";

I expect the output to be:

Mon, 08 May 2006 00:00:00 -0400
Wed, 15 May 2006 00:00:00 -0400
Wed, 22 May 2006 00:00:00 -0400
Mon, 29 May 2006 00:00:00 -0400
Mon, 05 Jun 2006 00:00:00 -0400

but the actual output (with PHP 5.1.4) is:

Mon, 08 May 2006 00:00:00 -0400
Wed, 31 Dec 1969 19:00:00 -0500
Wed, 31 Dec 1969 19:00:00 -0500
Mon, 29 May 2006 00:00:00 -0400
Mon, 05 Jun 2006 00:00:00 -0400

With PHP 4.4.2, the actual output is:

Tue, 01 May 2001 00:00:00 -0400
Mon, 01 May 2006 00:00:01 -0400
Thu, 01 May 2003 00:00:00 -0400
Sat, 01 May 2004 00:00:00 -0400
Sun, 01 May 2005 00:00:00 -0400
 [2006-05-24 21:41 UTC] ramsey@php.net
Actually, I meant that I expect the output to be (Wed should be changed to Mon):

Mon, 08 May 2006 00:00:00 -0400
Mon, 15 May 2006 00:00:00 -0400
Mon, 22 May 2006 00:00:00 -0400
Mon, 29 May 2006 00:00:00 -0400
Mon, 05 Jun 2006 00:00:00 -0400
 [2006-08-01 22:19 UTC] tony2001@php.net
strtotime("May 1st third Monday") returns false in the latest CVS and I think the result is correct, since the date is invalid.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 11:01:28 2024 UTC