Bug #76822 [Opn]: DateTime mircoseconds rounding issue

From: Date: Tue, 01 Sep 2020 14:03:41 +0000
Subject: Bug #76822 [Opn]: DateTime mircoseconds rounding issue
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228843@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76822&edit=1

 ID:                 76822
 Updated by:         cmb@php.net
 Reported by:        jamesin dot hongkong dot 1 at gmail dot com
 Summary:            DateTime mircoseconds rounding issue
 Status:             Open
 Type:               Bug
 Package:            Date/time related
 Operating System:   any
 PHP Version:        7.2.9
 Block user comment: N
 Private report:     N

 New Comment:

As of PHP 7.2.0, the microseconds are no longer stored as doubles,
but rather as integers.  Apparently, when parsing the
microseconds, these are just truncated to six decimal places.


Previous Comments:
------------------------------------------------------------------------
[2018-08-30 20:01:38] jamesin dot hongkong dot 1 at gmail dot com

Description:
------------
Some of our integration tests suddenly fail on PHP7.2+ due to a rounding issue in regards to
DateTime/microseconds.

## Reproducible example

```
Output for hhvm-3.18.5 - 3.22.0, 7.2.0 - 7.3.0beta2
2011-01-01 15:03:01.888499

Output for 5.6.30, 7.0.28 - 7.1.21
2011-01-01 15:03:01.888500
```

https://3v4l.org/al15I

Test script:
---------------
$d = new DateTime('2011-01-01T15:03:01.88849994Z');
print $d->format( 'Y-m-d H:i:s.u' );

Expected result:
----------------
2011-01-01 15:03:01.888500

Actual result:
--------------
2011-01-01 15:03:01.888499


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=76822&edit=1


Thread (3 messages)

« previous php.bugs (#228843) next »