From: salathe Operating system: PHP version: trunk-SVN-2011-09-13 (SVN) Package: Date/time related Bug Type: Bug Bug description:DateTime object getting stuck on Feb 29th
Description: ------------ Some dates falling on February 29th in negative years can not have an interval of one day added to them. The pattern appears to be years of the form -n16, but some years behave as expected (e.g. -816 and -416 in the test script below). Test script: --------------- <?php for ($i = -1000; $i < 1000; $i++) { $date = new DateTime('midnight', new DateTimeZone('UTC')); $date->setDate($i, 2, 29); // Rolled over into March, no Feb 29th, skip if ($date->format('M') !== 'Feb') { continue; } $next = clone $date; $next->add(new DateInterval('P1D')); if ($date->format('Y-m-d') === $next->format('Y-m-d')) { echo $next->format('Y-m-d l') . PHP_EOL; } } ?> Expected result: ---------------- No output is expected. Actual result: -------------- -0916-02-29 Friday -0716-02-29 Tuesday -0616-02-29 Sunday -0516-02-29 Friday -0316-02-29 Tuesday -0216-02-29 Sunday -0116-02-29 Friday -- Edit bug report at https://bugs.php.net/bug.php?id=55686&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55686&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55686&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55686&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55686&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55686&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55686&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55686&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55686&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55686&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55686&r=support Expected behavior: https://bugs.php.net/fix.php?id=55686&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55686&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55686&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55686&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55686&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=55686&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55686&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55686&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55686&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55686&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55686&r=mysqlcfg