From: tom at ix dot tc Operating system: Windows Vista PHP version: 5.2.9 PHP Bug Type: Date/time related Bug description: DateTime2 sometimes allows construct with an invalid string
Description: ------------ I was initialising DateTime objects to test validity of date strings when I came across an odd bug. The string "East Anglia" gets parsed the same way as some time today. Strangely, strtotime does not parse the string. Reproduce code: --------------- $date = new DateTime('AAAAA'); echo $date->format('U'); will correctly throw an exception: Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [<a href='datetime.--construct'>datetime.--construct</a>]: Failed to parse time string (AAA) at position 0 (A): $date = new DateTime('East Anglia'); echo $date->format('U'); Gets parsed as if it were now + 7 hours. Expected result: ---------------- An exception: Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [<a href='datetime.--construct'>datetime.--construct</a>]: Failed to parse time string (AAA) at position 0 (A): Actual result: -------------- Gets parsed as a time string. -- Edit bug report at http://bugs.php.net/?id=48334&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48334&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48334&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48334&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48334&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48334&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48334&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48334&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48334&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48334&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48334&r=support Expected behavior: http://bugs.php.net/fix.php?id=48334&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48334&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48334&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48334&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48334&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48334&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48334&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48334&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48334&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48334&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48334&r=mysqlcfg