Bug #73837 [NEW]: "new DateTime()" sometimes returns 1 second ago value on PHP 7.1.0
| From: | for-bugs at hnw dot jp | Date: | Thu, 29 Dec 2016 19:25:14 +0000 |
| Subject: | Bug #73837 [NEW]: "new DateTime()" sometimes returns 1 second ago value on PHP 7.1.0 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-206230@lists.php.net to get a copy of this message | ||
From: for-bugs at hnw dot jp
Operating system: macOS
PHP version: 7.1.0
Package: Date/time related
Bug Type: Bug
Bug description:"new DateTime()" sometimes returns 1 second ago value on PHP 7.1.0
Description:
------------
From PHP 7.1, DateTime constructor fills microseconds. However, setting
seconds and setting microseconds are in different function, so sometimes
DateTime instance has 1 second ago value from actual time.
Test script:
---------------
<?php
$prev_dt = new DateTime();
while (true) {
$dt = new DateTime();
if ($prev_dt > $dt) {
var_dump($prev_dt->format("Y-m-d H:i:s.u"));
var_dump($dt->format("Y-m-d H:i:s.u"));
break;
}
$prev_dt = $dt;
}
Expected result:
----------------
infinite loop
Actual result:
--------------
soon ends and outputs like this:
string(26) "2016-12-29 18:35:54.999998"
string(26) "2016-12-29 18:35:54.000000"
--
Edit bug report at https://bugs.php.net/bug.php?id=73837&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73837&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73837&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73837&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73837&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73837&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73837&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73837&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73837&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73837&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73837&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73837&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73837&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73837&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73837&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73837&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73837&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73837&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73837&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73837&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73837&r=mysqlcfg