ID:               41547
 User updated by:  noisex at apollo dot lv
-Summary:          strtotiem bug
 Reported By:      noisex at apollo dot lv
 Status:           Open
 Bug Type:         Date/time related
 Operating System: FreeBSD 6.2
 PHP Version:      5.2.2
 New Comment:

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


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

[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