php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75222 DateInterval microseconds property always 0
Submitted: 2017-09-18 10:36 UTC Modified: 2017-09-25 19:00 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: chris at cs278 dot org Assigned: jhdxr (profile)
Status: Closed Package: Date/time related
PHP Version: 7.2.0RC2 OS: Linux
Private report: No CVE-ID: None
 [2017-09-18 10:36 UTC] chris at cs278 dot org
Description:
------------
If you compute the difference between two DateTimeImmutable objects that differ only by microseconds the difference is correctly calculated (visible by var_dump) but the property value is 0.0.

This problem seems to have begun in 7.2.0RC1, betas are not affected.

https://3v4l.org/sM32U

Test script:
---------------
$dt1 = new \DateTimeImmutable('2017-01-01T00:00:00.000000Z');
$dt2 = new \DateTimeImmutable('2017-01-01T00:00:00.123456Z');
$diff = $dt2->diff($dt1);
//var_dump($diff);
var_dump($diff->f);
var_dump(get_object_vars($diff)['f']);
var_dump($diff->f === get_object_vars($diff)['f']);


Expected result:
----------------
float(0.123456)
float(0.123456)
bool(true)

Actual result:
--------------
float(0)
float(0.123456)
bool(false)


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-09-25 19:00 UTC] jhdxr@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: jhdxr
 [2017-09-27 05:25 UTC] krakjoe@php.net
Automatic comment on behalf of jhdxr
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7deb561f75b74ddf537e8da3efb4498ba5911043
Log: fix bug #75222 DateInterval microseconds property always 0
 [2017-09-27 05:25 UTC] krakjoe@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC