php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43169 Wrong date using strtotime('-1 month')
Submitted: 2007-11-01 12:29 UTC Modified: 2007-11-01 12:39 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: php at dredzik dot pl Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.4 OS: Windows XP SP/2
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: php at dredzik dot pl
New email:
PHP Version: OS:

 

 [2007-11-01 12:29 UTC] php at dredzik dot pl
Description:
------------
I use this code to generate timestamp for current and last month and everything worked fine until yesterday (31 October 2007). 

Today everything came back to normal - but when I set the date to yesterday on my system it keeps getting back. 

Reproduce code:
---------------
echo date('Y-m', strtotime('now')) . "\n";
echo date('Y-m', strtotime('-1 month'));

Expected result:
----------------
2007-10
2007-09

Actual result:
--------------
2007-10
2007-10

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-01 12:37 UTC] php at dredzik dot pl
There was very similiar bug to this one reported over 2 years ago, but since no one seems to have found a solution, I'm resubmitting just to remind you about it.
 [2007-11-01 12:39 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

2007-10-31 -1 month = 2007-09-31, which turns into 2007-10-01.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jun 03 01:01:26 2025 UTC