php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27195 strtotime problems
Submitted: 2004-02-09 12:21 UTC Modified: 2004-02-09 12:33 UTC
From: sinner_zero at hotmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.4 OS: Linux 2.4.19
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:
33 - 9 = ?
Subscribe to this entry?

 
 [2004-02-09 12:21 UTC] sinner_zero at hotmail dot com
Description:
------------
Calling strtotime("-1 month",$date)
when
$date = march 30th
returns March 1st instead of february 30th (which actually doesn't exist in 2004), I would assume this means it should return February 29th or something close.

Reproduce code:
---------------
<?php
$date = date("2004-03-30");

$previousMonth = date("Y-m-d",strtotime("-1 month",strtotime($date)));

echo $previousMonth;
?>

Expected result:
----------------
2004-02-??

?? could be anything between 01 and 29.


Actual result:
--------------
2004-03-01


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-09 12:33 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

Already reported before too, but it is correct like this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 09:01:30 2024 UTC