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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 14:01:35 2025 UTC