php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36912 strtotime subtracting months
Submitted: 2006-03-29 13:35 UTC Modified: 2006-03-29 16:24 UTC
From: epilepticfridgeboy at hotmail dot com Assigned: derick (profile)
Status: Not a bug Package: Date/time related
PHP Version: 5.1.2 OS: debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: epilepticfridgeboy at hotmail dot com
New email:
PHP Version: OS:

 

 [2006-03-29 13:35 UTC] epilepticfridgeboy at hotmail dot com
Description:
------------
Subtracting a month using strtotime does not always subtract a month.

Reproduce code:
---------------
<?php
print date('Y-m-d', strtotime('-1 month'));
?>


Expected result:
----------------
Assuming the code is run on 2006-03-29, I would expect the result to be 2006-02-28, which is one month ago.

Actual result:
--------------
2006-03-01

This is not one month ago. This has been reported as a bug before but marked as "Bogus" - no idea how not subtracting one month from a date correctly is bogus... and I wasn't allowed to add this to the notes system in the manual to warn others about this odd behaviour., so here it is again as a bug report.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-29 16:24 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

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 14:01:30 2024 UTC