|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75642 Wrap around behaviour for microseconds is not working
Submitted: 2017-12-06 22:11 UTC Modified: 2018-10-11 16:29 UTC
Avg. Score:3.8 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:0 (0.0%)
From: marcospassos dot com at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 7.2.0 OS: OSX
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: marcospassos dot com at gmail dot com
New email:
PHP Version: OS:


 [2017-12-06 22:11 UTC] marcospassos dot com at gmail dot com
When adding 1 microsecond to 999999 does not increment the seconds part.

Test script:
$date = new \DateTime('2017-12-31 23:59:59.999999');

echo $date->format('Y-m-d H:i:s.u');
echo "\n";
echo $date->modify('+1 microsecond')->format('Y-m-d H:i:s.u');

Expected result:
2017-12-31 23:59:59.999999
2016-01-01 00:00:00.000000

Actual result:
2017-12-31 23:59:59.999999
2017-12-31 23:59:59.1000000


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-06 22:12 UTC] marcospassos dot com at gmail dot com
Expected result:
2017-12-31 23:59:59.999999
2018-01-01 00:00:00.000000
 [2017-12-06 22:26 UTC] spam2 at rhsoft dot net
pretty sure the sad float precision problem which makes me wonder why it's called computer and not guesser
 [2018-01-21 19:12 UTC] marcospassos dot com at gmail dot com
Any update about this issue?
 [2018-03-09 12:06 UTC]
-Status: Open +Status: Verified
 [2018-03-09 12:06 UTC]
> pretty sure the sad float precision problem

Apparently[1].  However, `2017-12-31 23:59:59.1000000` is wrong

[1] <>
 [2018-03-09 15:06 UTC]
Microseconds are actually their own distinct integer.

Off by one error.

Additionally it's only able to over-/underflow the seconds by a change of 2.
 [2018-04-23 14:21 UTC]
-Assigned To: +Assigned To: derick
 [2018-04-23 14:21 UTC]
I've filed a respective ticket upstream[1]:
 [2018-06-06 14:08 UTC] german dot drulyk at gmail dot com
Confirmed reproduce-able on:

Windows 7 x64
PHP x64 7.1.16 and 7.2.4
 [2018-10-11 15:59 UTC]
This is fixed for PHP 7.3.0RC4, by upgrading timelib (See: #75577)
 [2018-10-11 16:29 UTC]
-Status: Verified +Status: Closed
 [2018-10-11 16:29 UTC]
So this can be closed (I assume there will be no back-port of the
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Apr 13 14:01:23 2021 UTC