Bug #74753 [Asn->Csd]: Function "date_format()" displays "1000" milliseconds after "999"

From: Date: Fri, 29 Sep 2017 15:11:42 +0000
Subject: Bug #74753 [Asn->Csd]: Function "date_format()" displays "1000" milliseconds after "999"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211458@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74753&edit=1 ID: 74753 Updated by: salathe@php.net Reported by: iyeo at ya dot ru Summary: Function "date_format()" displays "1000" milliseconds after "999" -Status: Assigned +Status: Closed Type: Bug Package: Date/time related Operating System: (x64):Windows 8.1, Xubuntu 16.04 PHP Version: 7.1.6 Assigned To: derick Block user comment: N Private report: N New Comment: This appears to be fixed as of PHP 7.2.0rc1. Example script: $dateTime = new \DateTime('2017-09-29 17:44:48.999600'); var_dump($dateTime->format('Y-m-d H:i:s.v')); Output for 7.0.0 to 7.2.0beta3: string(24) "2017-09-29 17:44:48.1000" Output for 7.2.0rc1 to 7.2.0rc2: string(23) "2017-09-29 17:44:48.999" Previous Comments: ------------------------------------------------------------------------ [2017-06-23 15:00:55] requinix@php.net Related To: Bug #74803 ------------------------------------------------------------------------ [2017-06-13 09:52:36] requinix@php.net Due to the rounding also being done this will happen for microseconds >= 0.999500. https://3v4l.org/NNDZV ------------------------------------------------------------------------ [2017-06-13 09:20:22] iyeo at ya dot ru Description: ------------ Function date_format($now, "Y-m-d\TH:m:s.v") returns "1000" milliseconds after "999", but it must be a "000". Test script: --------------- <?php for ($i = 0; $i < 3000; $i++) { $now = new DateTime(); $t = date_format($now, "Y-m-d\TH:m:s.v"); echo $t . "<br>"; } ?> Expected result: ---------------- 2017-06-13T11:06:22.998 2017-06-13T11:06:22.999 2017-06-13T11:06:23.000 Actual result: -------------- 2017-06-13T11:06:22.998 2017-06-13T11:06:22.999 2017-06-13T11:06:22.1000 2017-06-13T11:06:23.000 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74753&edit=1

« previous php.bugs (#211458) next »