Edit report at http://bugs.php.net/bug.php?id=46597&edit=1
ID: 46597 Comment by: fsb at thefsb dot org Reported by: fsb at thefsb dot org Summary: Inconsistent return values for strtotime('0000-00-00') Status: Bogus Type: Bug Package: Date/time related Operating System: * PHP Version: 5.*, 6CVS (2009-04-30) New Comment: ahar...@php.net: Any date with month=zero or day=zero is invalid, regardless of the year value. '0000-00-00' is not a date and has no corresponding unix timestamp. Previous Comments: ------------------------------------------------------------------------ [2010-03-31 05:17:47] ahar...@php.net This isn't a bug. The year 0 is well within the range of a 64-bit UNIX timestamp, strtotime's semantics for invalid values (such as defining the month and day as 0) are well established at this point, and I see little value in special casing 0000-00-00 and plenty of possible WTFs down the line if it's done. ------------------------------------------------------------------------ [2010-03-30 22:09:56] contractfrombelow at gmail dot com We are getting this same problem, but only on 64 bit platforms. I've tested on a few different machines, all 64 bit machines return int(-62169955200). 32 bit machines return bool(false) as expected. This happens on 5.2.x and 5.3.x. ------------------------------------------------------------------------ [2009-01-16 18:24:50] marco at tumis dot com I've reproduced this on CentOS with kernel 2.6.9-55.ELsmp using php version: PHP 5.2.8 (cli) (built: Jan 5 2009 15:01:45) and the 5.2.8 apache module. And I think it should go back to returning bool(false). ------------------------------------------------------------------------ [2008-11-17 18:33:04] fsb at thefsb dot org i was wrong with the expected results. a year of 0000 is reasonable but neither month = 00 nor day of of the month = 00 are possible, so the strtotime('0000-00-00') should return bool(false) ------------------------------------------------------------------------ [2008-11-17 17:41:21] fsb at thefsb dot org Description: ------------ strtotime('0000-00-00') returns int(-62169955200) in a script run by apache web server and bool(false) when run by the command line. Reproduce code: --------------- <?php var_dump(strtotime('0000-00-00')); ?> this script outputs int(-62169955200) to the web browser when run as a web page and bool(false) when run on the command line. Expected result: ---------------- i would expect the same result from running the function in the two contexts. regarding which result strtotime('0000-00-00') should return, i don't know. both answers seem reasonable to me. it would help if php documentation would specify the range of dates and unix timestamps that date and time functions can handle. Actual result: -------------- int(-62169955200) in the web page bool(false) in the command line ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=46597&edit=1