From: Operating system: PHP version: 5.3.8 Package: Date/time related Bug Type: Bug Bug description:DateTime validation is incomplete
Description: ------------ DateTime validation is incomplete. According to DateTime::__construct documentation this is not a bug: // Non-existent values roll over. $date = new DateTime('2000-02-30'); echo $date->format('Y-m-d H:i:sP') . "\n"; I disagree. There should be at least some way to require a proper validation (such as checkdate() function provides) for input dates. If you think this is incorrect behavior and rolling over is the desired one, then please implement the rolling so that one can for example give "2000-02-37" as the argument. Now DateTime checks the day of the month like this: 0 <= x <= 31. Test script: --------------- <?php $date = new DateTime('2011-02-31'); print $date->format('Y-m-d'); $date = new DateTime('2011-02-32'); print $date->format('Y-m-d'); ?> Expected result: ---------------- Both DateTime constructors should throw an Exception describing that the date is invalid. Actual result: -------------- Now the constructor with '2011-02-32' as its parameter is the only one throwing Exception about invalid date. -- Edit bug report at https://bugs.php.net/bug.php?id=60650&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60650&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60650&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60650&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60650&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60650&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60650&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60650&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60650&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60650&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60650&r=support Expected behavior: https://bugs.php.net/fix.php?id=60650&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60650&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60650&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60650&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60650&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60650&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60650&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60650&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60650&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60650&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60650&r=mysqlcfg