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-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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kylekatarnls at gmail dot com
New email:
PHP Version: OS:

 

 [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.
 [2021-08-08 16:28 UTC] derick@php.net
-Status: Assigned +Status: Closed
 [2021-08-08 16:28 UTC] derick@php.net
The fix for this bug has been committed.
If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src 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: Tue Mar 19 04:01:31 2024 UTC