Edit report at http://bugs.php.net/bug.php?id=51439&edit=1
ID: 51439 Updated by: der...@php.net Reported by: ml at stefanbongartz dot de Summary: "last month" in date does not right on March 30th -Status: Open +Status: Bogus Type: Bug Package: *General Issues Operating System: Ubuntu 9.x, Debian 4.x PHP Version: 5.3.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 http://derickrethans.nl/obtaining-the-next-month-in-php.html Previous Comments: ------------------------------------------------------------------------ [2010-03-30 14:32:43] ml at stefanbongartz dot de Description: ------------ On March 30th and 31th the date function does not work correctly. If you work with date("m")-1 the result is not 02 for the month. You get 03 for the month but 02 for the day!! If you change the system clock to another date the funtion works correctly. See code below. If you set the clock to Apr 30th and use date('m')-2 you get the same wrong result. Test script: --------------- echo "<br>today: ". $today = mktime(0, 0, 0, date("m") , date("d"), date("Y")); echo "<br>". date('d.m.Y', $today); echo "<br>"; echo "<br>tomorrow: ". $tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y")); echo "<br>". date('d.m.Y', $tomorrow); echo "<br>"; echo "<br>last1month: ". $lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); echo "<br>". date('d.m.Y', $lastmonth); echo "<br>"; echo "<br>last2month: ". $lastmonth = mktime(0, 0, 0, date("m")-2, date("d"), date("Y")); echo "<br>". date('d.m.Y', $lastmonth); echo "<br>"; echo "<br>last3month: ". $lastmonth = mktime(0, 0, 0, date("m")-3, date("d"), date("Y")); echo "<br>". date('d.m.Y', $lastmonth); echo "<br>"; Expected result: ---------------- 30.02.2010 Actual result: -------------- 02.03.2010 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51439&edit=1