php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62980 strtotime bug
Submitted: 2012-08-31 08:19 UTC Modified: 2012-08-31 08:21 UTC
From: mailzsm at 126 dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.16 OS: linux redhat4.5
Private report: No CVE-ID: None
 [2012-08-31 08:19 UTC] mailzsm at 126 dot com
Description:
------------
---
intro
today is 2012-08-31
echo  date("Y-m-d",strtotime("- 1 months")); =====>2012-07-31
echo  date("Y-m-d",strtotime("- 2 months")); =====>2012-07-01  (why)
echo  date("Y-m-d",strtotime("- 3 months")); =====>2012-05-31


From manual page: http://www.php.net/function.strtotime#refsect1-
function.strtotime-description
---



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-31 08:21 UTC] aharvey@php.net
You're asking strtotime() to subtract months, and August has 31 days. So:

-1 month  = July 31.
-2 months = June 31. June only has 30 days, though, so it becomes July 1.
-3 months = May 31.

And so on.
 [2012-08-31 08:21 UTC] aharvey@php.net
-Status: Open +Status: Not a bug -Type: Documentation Problem +Type: Bug -Package: CGI/CLI related +Package: Date/time related
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Apr 05 01:01:24 2020 UTC