php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77121 fractions in diff cause overflow in same second datetimes
Submitted: 2018-11-08 08:55 UTC Modified: 2018-11-08 11:24 UTC
From: sakari dot laine at verkkokauppa dot com Assigned: cmb (profile)
Status: Duplicate Package: Date/time related
PHP Version: 7.2.12 OS: linux
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sakari dot laine at verkkokauppa dot com
New email:
PHP Version: OS:

 

 [2018-11-08 08:55 UTC] sakari dot laine at verkkokauppa dot com
Description:
------------
Datetime diff overflows if fractions and no fractions in same second.

Test script:
---------------
$date = new \DateTime('2018-11-08 10:22:43');
$date2 = new \DateTime('2018-11-08 10:22:43.123456');


print_r($date2->diff($date));


Expected result:
----------------
DateInterval Object
(
    [y] => 0
    [m] => 0
    [d] => 0
    [h] => 0
    [i] => 0
    [s] => 0
    [f] => -0.123456
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 0
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)

Actual result:
--------------
DateInterval Object
(
    [y] => -1
    [m] => 11
    [d] => 30
    [h] => 23
    [i] => 59
    [s] => 59
    [f] => 0.876544
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 0
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-08 09:55 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2018-11-08 09:55 UTC] cmb@php.net
This looks like a duplicate of bug #77097.
 [2018-11-08 11:24 UTC] sakari dot laine at verkkokauppa dot com
-PHP Version: 7.2.12RC1 +PHP Version: 7.2.12
 [2018-11-08 11:24 UTC] sakari dot laine at verkkokauppa dot com
Affects 7.2.12 but at the time of submitting it was not present in dropdown,
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 20:01:29 2024 UTC