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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
39 - 19 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 23:01:34 2024 UTC