#30190 [NEW]: strtotime doesn't return -1 from 0000-00-00

From: Date: Wed, 22 Sep 2004 01:19:16 +0000
Subject: #30190 [NEW]: strtotime doesn't return -1 from 0000-00-00
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-66530@lists.php.net to get a copy of this message
From: mike dot deeks at equest dot com Operating system: Debian, Linux PHP version: 4.3.8 PHP Bug Type: Date/time related Bug description: strtotime doesn't return -1 from 0000-00-00 Description: ------------ strtotime returns the date 1999-11-31 (Timestamp: 943948800) instead of -1 when I pass it "0000-00-00". From what I can tell, it assumes 0000 is the year 2000. Then the 00 month and 00 day refer to the previous month and the previous day from the year 2000. i.e. "2000-01-01" minus one month, and one day. Should it not return a -1 because that is an invalid time? "0000-00-00" is what MySQL defaults invalid DATE values to by the way. Reproduce code: --------------- echo strtotime("2000-01-01") . "/n"; echo strtotime("2000-01-00") . "/n"; echo strtotime("2000-00-00") . "/n"; echo strtotime("0000-00-00") . "/n"; Expected result: ---------------- 946713600 946627200 -1 -1 Actual result: -------------- 946713600 946627200 943948800 943948800 -- Edit bug report at http://bugs.php.net/?id=30190&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30190&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30190&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30190&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30190&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30190&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30190&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30190&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30190&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30190&r=support Expected behavior: http://bugs.php.net/fix.php?id=30190&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30190&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30190&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30190&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30190&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30190&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30190&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30190&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30190&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30190&r=mysqlcfg

« previous php.bugs (#66530) next »