|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80998 Missing second with inverted interval
Submitted: 2021-04-28 09:07 UTC Modified: 2021-08-08 16:28 UTC
From: kylekatarnls at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: master-Git-2021-04-28 (Git) OS: Ubuntu
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: kylekatarnls at gmail dot com
New email:
PHP Version: OS:


 [2021-04-28 09:07 UTC] kylekatarnls at gmail dot com
When adding an inverted interval containing microseconds, 1 second miss in the final result (with PHP >= 8.1 but not < 8.1)


Test script:
$date = new DateTime('2021-04-05 14:00:00');
$interval = new DateInterval('P0DT10799S');
$interval->f = 0.999999;
$interval->invert = 1;
$string = $date->format('Y-m-d H:i:s.u');

echo $string;

Expected result:
2021-04-05 11:00:00.000001

Actual result:
2021-04-05 11:00:01.000001


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-05 15:27 UTC]
-Assigned To: +Assigned To: derick
 [2021-05-05 15:27 UTC]
Derick, there might be an issue with timelib 2021.3.
 [2021-08-08 16:28 UTC]
-Status: Assigned +Status: Closed
 [2021-08-08 16:28 UTC]
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from and re-test.
Thank you for the report, and for helping us make PHP better.

Fixed for 8.1.0beta3.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 30 05:01:31 2024 UTC