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

From: Date: Mon, 14 Oct 2019 14:44:44 +0000
Subject: Bug #78673 [Opn->Ver]: Wrong results for DateTime->modify() with milliseconds
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223203@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78673&edit=1 ID: 78673 Updated by: sjon@php.net Reported by: dse at newpharma dot ro Summary: Wrong results for DateTime->modify() with milliseconds -Status: Open +Status: Verified Type: Bug Package: Date/time related PHP Version: Irrelevant Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2019-10-14 13:55:30] dse at newpharma dot ro 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 this bug report at https://bugs.php.net/bug.php?id=78673&edit=1

« previous php.bugs (#223203) next »