From: Operating system: Ubuntu 9.x, Debian 4.x PHP version: 5.3.2 Package: *General Issues Bug Type: Bug Bug description:"last month" in date does not right on March 30th
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 bug report at http://bugs.php.net/bug.php?id=51439&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51439&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51439&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51439&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51439&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51439&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51439&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51439&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51439&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51439&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51439&r=support Expected behavior: http://bugs.php.net/fix.php?id=51439&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51439&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51439&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51439&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51439&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51439&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51439&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51439&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51439&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51439&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51439&r=mysqlcfg