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
 [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

Pull Requests

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: Sat Dec 21 12:01:31 2024 UTC