ID:               41547
 Updated by:       [EMAIL PROTECTED]
 Reported By:      noisex at apollo dot lv
-Status:           Open
+Status:           Bogus
 Bug Type:         Date/time related
 Operating System: FreeBSD 6.2
 PHP Version:      5.2.2
 New Comment:

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

Your are incorrect in your assessment. The "+-n months" statement goes
back one month. Back from May 31st that becomes April 31st. As April
only has 30 days this turns into May 1st. The same is true February,
which only has 28 days, so the result is March 3rd. See the following
script:

<?php
for($i=1; $i<=12; $i++) {
    echo date("Y-M-d H:i:s",strtotime("-$i months"))."<br/>\n";
}
?>


Previous Comments:
------------------------------------------------------------------------

[2007-05-31 09:25:19] noisex at apollo dot lv

The result must be (sorry): 
2007-Apr
2007-Mar
2007-Feb
2007-Jan
2006-Dec
2006-Nov
2006-Oct
2006-Sep
2006-Aug
2006-Jul
2006-Jun
2006-May

------------------------------------------------------------------------

[2007-05-31 09:21:33] noisex at apollo dot lv

Description:
------------
On months with 31th day the strtotime function with +/-$foo month
calculates wrong. it calculates -30 days not 31 days.

Reproduce code:
---------------
Simple example (running today 31 May):

<?php
for($i=1; $i<=12; $i++) {
echo date("Y-M",strtotime("-$i months"))."<br>";
}
?>

Expected result:
----------------
2007-Mar
2007-Feb
2007-Jan
2006-Dec
2006-Nov
2006-Oct
2006-Sep
2006-Aug
2006-Jul
2006-Jun
2006-May
2006-Apr

Actual result:
--------------
2007-May
2007-Mar
2007-Mar
2007-Jan
2006-Dec
2006-Dec
2006-Oct
2006-Oct
2006-Aug
2006-Jul
2006-Jul
2006-May


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41547&edit=1

Reply via email to