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
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: mailzsm at 126 dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sun Dec 22 03:01:28 2024 UTC