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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
48 - 9 = ?
Subscribe to this entry?

 
 [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: Tue Aug 03 18:01:24 2021 UTC