Bug #73294 [NEW]: DateTime wrong when date string is negative

From: Date: Tue, 11 Oct 2016 16:42:07 +0000
Subject: Bug #73294 [NEW]: DateTime wrong when date string is negative
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204606@lists.php.net to get a copy of this message
From: andrmoel at googlemail dot com Operating system: Ubuntu PHP version: 7.0.11 Package: Date/time related Bug Type: Bug Bug description:DateTime wrong when date string is negative Description: ------------ When you run the test script, the second outpot is parsed false. It returns the date minus one day. Maybe this error occures with other strings also. Test script: --------------- <?php $dt = new DateTime('-1999-06-22 00:00:00'); echo "\nThis should be -1999-06-22 00:00:00 -> " . $dt->format('Y-m-d H:i:s'); $dt = new DateTime('-1916-06-22 00:00:00'); echo "\nThis should be -1916-06-22 00:00:00 -> " . $dt->format('Y-m-d H:i:s'); Expected result: ---------------- This should be -1999-06-22 00:00:00 -> -1999-06-22 00:00:00 This should be -1916-06-22 00:00:00 -> -1916-06-22 00:00:00 Actual result: -------------- This should be -1999-06-22 00:00:00 -> -1999-06-22 00:00:00 This should be -1916-06-22 00:00:00 -> -1916-06-21 00:00:00 -- Edit bug report at https://bugs.php.net/bug.php?id=73294&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73294&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73294&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73294&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73294&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73294&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73294&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73294&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73294&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73294&r=support Expected behavior: https://bugs.php.net/fix.php?id=73294&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73294&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73294&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73294&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73294&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73294&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73294&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73294&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73294&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73294&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73294&r=mysqlcfg

« previous php.bugs (#204606) next »