From: daniel at septum dot org Operating system: Linux 2.4 PHP version: 6CVS-2005-11-01 (snap) PHP Bug Type: Date/time related Bug description: mktime() seems to return odd results for 31st of October
Description: ------------ When involving the 31st of October (either by finding out number of days between 2005-10-29 and 2005-10-31 or 2005-10-31 and 2005-11-01), it gives the wrong result. Days between 2005-10-29 and 2005-10-30 returns 1 (which is correct), however, days between 2005-10-29 and 2005-10-31 returns 3 (which is incorrect, it should be 2). It seems to work fine for 2001, 2002, 2003 and 2006-2009, not for 2004 and 2005 (as stated above). Reproduce code: --------------- $dos = "2005-10-30"; $year = substr($dos, 0, 4); $month = substr($dos, 5, 2); $day = substr($dos, 8, 2); $mktime_dos = mktime(0, 0, 0, $month, $day, $year); $next_month = "2005-11-01"; $year = substr($next_month, 0, 4); $month = substr($next_month, 5, 2); $day = substr($next_month, 8, 2); $mktime_now = mktime(0, 0, 0, $month, $day, $year); $difference = $mktime_now - $mktime_dos; $signed_up_days_ago = ceil($difference / 60 / 60 / 24); echo $signed_up_days_ago . "\n"; Expected result: ---------------- 2 Actual result: -------------- 3 -- Edit bug report at http://bugs.php.net/?id=35043&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35043&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=35043&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=35043&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=35043&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=35043&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=35043&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=35043&r=needscript Try newer version: http://bugs.php.net/fix.php?id=35043&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=35043&r=support Expected behavior: http://bugs.php.net/fix.php?id=35043&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=35043&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=35043&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=35043&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35043&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=35043&r=dst IIS Stability: http://bugs.php.net/fix.php?id=35043&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=35043&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=35043&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=35043&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=35043&r=mysqlcfg