Edit report at http://bugs.php.net/bug.php?id=53431&edit=1
ID: 53431 User updated by: adam-phpbugs at adam dot gs Reported by: adam-phpbugs at adam dot gs Summary: strtotime/DateTime object return incorrect results for invalid date/times Status: Open Type: Bug Package: Date/time related Operating System: ALL PHP Version: Irrelevant Block user comment: N Private report: N New Comment: I, obviously, swapped expected and actual here. Previous Comments: ------------------------------------------------------------------------ [2010-12-01 03:33:49] adam-phpbugs at adam dot gs Description: ------------ When given an invalid date/time both strtotime and the DateTime object returns the current day at midnight instead Test script: --------------- [a...@nighe]$ php -r '$x=strtotime("2011-00-00");printf("%s\n",date("Y-m-d H:i:s",$x));' 2010-11-30 00:00:00 [a...@nighe]$ php -r '$x=new DateTime("2011-00-00");var_dump($x);' object(DateTime)#1 (3) { ["date"]=> string(19) "2010-11-30 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "America/New_York" } Expected result: ---------------- returns current day at midnight Actual result: -------------- strtotime should return FALSE DateTime should throw an Exception. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53431&edit=1