Bug #77121 [NEW]: fractions in diff cause overflow in same second datetimes
| From: | sakari dot laine at verkkokauppa dot com | Date: | Thu, 08 Nov 2018 08:55:44 +0000 |
| Subject: | Bug #77121 [NEW]: fractions in diff cause overflow in same second datetimes | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-217863@lists.php.net to get a copy of this message | ||
From: sakari dot laine at verkkokauppa dot com
Operating system: linux
PHP version: 7.2.12RC1
Package: Date/time related
Bug Type: Bug
Bug description:fractions in diff cause overflow in same second datetimes
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
)
--
Edit bug report at https://bugs.php.net/bug.php?id=77121&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77121&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77121&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77121&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77121&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77121&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77121&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77121&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77121&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77121&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77121&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77121&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77121&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77121&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77121&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77121&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77121&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77121&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77121&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77121&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77121&r=mysqlcfg