|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-12-01 09:20 UTC] remi@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: remi
[2012-12-01 09:26 UTC] remi@php.net
[2012-12-01 09:26 UTC] remi@php.net
-Status: Assigned
+Status: Closed
[2012-12-19 17:55 UTC] derick@php.net
[2014-10-07 23:21 UTC] stas@php.net
[2014-10-07 23:31 UTC] stas@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Description: ------------ When storing '015700' microseconds in a Datetime object, Datetime::format('u') returns '015699'. This behavior is critical when I use optimistic locking. ---- $datetime = Datetime::createFromFormat('u', '015700'); $datetime->format('u'); // => '015699' ---- Datetime objects hold microseconds as "double" type in C. '015700' is held as 0.015699999999999998679. Datetime::format('u') calls floor() and it returns .015699. (see https://github.com/php/php-src/blob/PHP-5.3.18/ext/date/php_date.c#L1098 ) Test script: --------------- $datetime = Datetime::createFromFormat('u', '015700'); $datetime->format('u'); Expected result: ---------------- 015700 Actual result: -------------- 015699