php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32103 strtotime() cant substract monts
Submitted: 2005-02-25 08:22 UTC Modified: 2005-02-25 14:23 UTC
From: zini10 at 012 dot net dot il Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.8 OS: Windows
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: zini10 at 012 dot net dot il
New email:
PHP Version: OS:

 

 [2005-02-25 08:22 UTC] zini10 at 012 dot net dot il
Description:
------------
strtotime() will not parse the following call the right way:
strtotime("2005-02-28 00:00:00 - 3 months")
but will parse this correctly:
strtotime("2005-02-28 00:00:00 + -3 months")



Reproduce code:
---------------
print date("Y-m-d h:m:s",strtotime("2005-02-28 00:00:00 - 3 months"));

print date("Y-m-d h:m:s",strtotime("2005-02-28 00:00:00 + -3 months"));

Expected result:
----------------
2004-11-25 12:11:00

Actual result:
--------------
2005-05-25 12:05:00

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-25 10:56 UTC] tony2001@php.net
<?
print date("Y-m-d h:m:s",strtotime("2005-02-28 00:00:00 -3 months"));
?>
works fine (note that there is no space between "-" and "3").
 [2005-02-25 14:23 UTC] sniper@php.net
strtotime() is not some intelligent being which can magically interpret anything you pass it. Ditch the space between - and 3 and it works.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 21 20:01:30 2024 UTC