|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12474 possible incorrect strtotime handling of "-1Month"
Submitted: 2001-07-30 20:53 UTC Modified: 2002-05-25 06:29 UTC
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: jbarrett at australink dot net Assigned:
Status: Closed Package: Date/time related
PHP Version: 4.0.4pl1 OS: Linux (should happen on any)
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:
Solve the problem:
13 + 38 = ?
Subscribe to this entry?

 [2001-07-30 20:53 UTC] jbarrett at australink dot net
when running
print date("d/m/Y", strtotime("31 July 2001"))."\n";
print date("d/m/Y", strtotime("-1 month", strtotime("31 July 2001")))."\n";

it replies with 
X-Powered-By: PHP/4.0.3pl1
Content-type: text/html


of course what it's doing is turning it into 31 june which is then being considered to be the 1 of july.. Should this be right or should strtotime realise that there are 30 days in june and truncate the "31st" day?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-20 03:48 UTC]
Confirmed with php 4.2.0-dev.

print date("d/m/Y", strtotime("1 month ago", strtotime("31 July 2001")))."\n";

Gives the same error, and that should be correct GNU date syntax?

 [2002-05-25 06:29 UTC]
Not really a bug, it's exactly like GNU date behaves:

[derick@kossu derick]$ date --date='31 July 2001 -1 month'
Sun Jul  1 00:00:00 CEST 2001
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Oct 04 14:01:25 2023 UTC