Bug #78673 [NEW]: Wrong results for DateTime->modify() with milliseconds

From: Date: Mon, 14 Oct 2019 13:55:30 +0000
Subject: Bug #78673 [NEW]: Wrong results for DateTime->modify() with milliseconds
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223202@lists.php.net to get a copy of this message
From: dse at newpharma dot ro Operating system: PHP version: Irrelevant Package: Date/time related Bug Type: Bug Bug description:Wrong results for DateTime->modify() with milliseconds Description: ------------ Adding or subtracting milliseconds from a DateTime object does not give the correct result. Test script: --------------- <?php $millisInThePast = 50000; $currentDate = new DateTime("2019-10-14T15:08:23.123+02:00"); echo 'Current: ' . $currentDate->format(DATE_RFC3339_EXTENDED) . "\n"; echo 'Past: ' . $currentDate->modify("-{$millisInThePast} msec")->format(DATE_RFC3339_EXTENDED); Expected result: ---------------- Current: 2019-10-14T15:08:23.123+02:00 Past: 2019-10-14T15:07:33.123+02:00 Actual result: -------------- Current: 2019-10-14T15:08:23.123+02:00 Past: 2019-10-14T15:08:21.-47877+02:00 -- Edit bug report at https://bugs.php.net/bug.php?id=78673&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78673&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78673&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78673&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78673&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78673&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78673&r=support Expected behavior: https://bugs.php.net/fix.php?id=78673&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78673&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78673&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78673&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78673&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78673&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78673&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78673&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78673&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78673&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78673&r=mysqlcfg

« previous php.bugs (#223202) next »