php.net |  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-05-05 15:27 UTC
From: kylekatarnls at gmail dot com Assigned: derick (profile)
Status: Assigned Package: Date/time related
PHP Version: master-Git-2021-04-28 (Git) OS: Ubuntu
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

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

See https://github.com/kylekatarnls/datetime-bug/runs/2456014545

Test script:
---------------
$date = new DateTime('2021-04-05 14:00:00');
$interval = new DateInterval('P0DT10799S');
$interval->f = 0.999999;
$interval->invert = 1;
$date->add($interval);
$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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-05 15:27 UTC] cmb@php.net
-Assigned To: +Assigned To: derick
 [2021-05-05 15:27 UTC] cmb@php.net
Derick, there might be an issue with timelib 2021.3.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Jun 18 01:01:25 2021 UTC