php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33869 Strtotime no longer parses +1day or +1year etc...
Submitted: 2005-07-26 17:38 UTC Modified: 2005-07-27 00:29 UTC
From: jeremy at techtrav dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.1.0b3 OS: Windows XP Apache 2
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: jeremy at techtrav dot com
New email:
PHP Version: OS:

 

 [2005-07-26 17:38 UTC] jeremy at techtrav dot com
Description:
------------
the newest snap of php 5.1.X does not parse strtotime properly for adding days.  This used to work in 5.0.4. Look at the reproduceable code below.  The new version only seems to work with a space between the number and the days or months or years.

Reproduce code:
---------------
$date = strtotime('20 Aug');
echo date('m/d/Y H:m:s', strtotime('+5days',$date));
echo '<br>';
echo date('m/d/Y H:m:s', strtotime('+1month',$date));
echo '<br>';
echo date('m/d/Y H:m:s', strtotime('+1year',$date));

Expected result:
----------------
08/25/2005 00:08:00
09/20/2005 00:09:00
08/20/2006 00:08:00 

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-26 17:45 UTC] tony2001@php.net
Because you should write "+1 day", instead of "+1day".
Notice the whitespace. 
 [2005-07-26 17:47 UTC] jeremy at techtrav dot com
If you would read my comment you would realize this worked in php 5.0.4.  I would assume you would like to keep PHP backwards compatable with peoples code!
 [2005-07-26 18:17 UTC] tony2001@php.net
Derick, is it intended change or not?
 [2005-07-27 00:29 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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 12:01:27 2024 UTC