Bug #68506 [NEW]: General DateTime improvments needed for microseconds to become useful
| From: | mfaust at usinternet dot com | Date: | Wed, 26 Nov 2014 13:27:16 +0000 |
| Subject: | Bug #68506 [NEW]: General DateTime improvments needed for microseconds to become useful | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-188800@lists.php.net to get a copy of this message | ||
From: mfaust at usinternet dot com
Operating system:
PHP version: master-Git-2014-11-26 (Git)
Package: Date/time related
Bug Type: Bug
Bug description:General DateTime improvments needed for microseconds to become useful
Description:
------------
There are several major issues with the current implementation of
DateTime in regards to microseconds that make it generally useless
as-is. Microseconds are critical for many reasons, including high
resolution logging in todays environments.
Here are a few additional observations made with microseconds in its
current state:
- They are not used for object comparisons. Internal comparisons
should take microseconds into account. This is seen as a bug.
- There is no way to change microseconds after object initialization.
setTime should have an optional 4th parameter added, and modify() should
also allow changing/setting of microseconds.
- They are not available in DateTimeInterval objects created from a
call to diff() or created directly.
- Various date functions that use timestamps should be able to use the
microseconds portion of the result from microtime(TRUE), for example
date('Y-m-d H:i:s.u', microtime(TRUE))
Test script:
---------------
//Proper date comparison
$a = new DateTime('2014-11-01 00:00:00.000001');
$b = new DateTime('2014-11-01 00:00:00.000002');
if($a == $b){
//should not happen
echo 'SAME';
}elseif($a < $b){
//should happen
echo 'DIFFERENT'
}
//Ability to change microseconds
$a->setTime(11, 30, 00, 123456);
//Diff output
$diff = $a->diff($b);
echo $diff->u;
--
Edit bug report at https://bugs.php.net/bug.php?id=68506&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68506&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68506&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68506&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68506&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68506&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68506&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68506&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68506&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68506&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68506&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68506&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68506&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68506&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68506&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68506&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68506&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68506&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68506&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68506&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68506&r=mysqlcfg