Req #64887 [Opn->Csd]: Add microseconds to DateTime::format
| From: | derick@php.net | Date: | Fri, 07 Oct 2016 17:44:19 +0000 |
| Subject: | Req #64887 [Opn->Csd]: Add microseconds to DateTime::format | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204534@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64887&edit=1
ID: 64887
Updated by: derick@php.net
Reported by: glass at glasshalfawesome dot com
Summary: Add microseconds to DateTime::format
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Date/time related
Operating System: Win7
PHP Version: Irrelevant
-Assigned To:
+Assigned To: derick
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Fixed for PHP 7.1.0RC4.
I added "ms", "msec", "µs", "usec", "µsec",
"millisecond", and "microsecond" (and plural versions) are also supported.
I did not add "decisecond" and "centisecond", but I *did* considering adding
microfortnights ;-)
(https://en.wikipedia.org/wiki/FFF_system#Microfortnight_and_other_decimal_prefixes
Previous Comments:
------------------------------------------------------------------------
[2013-05-21 07:09:18] glass at glasshalfawesome dot com
Description:
------------
From what I can find it's currently not possible to add or subtract microseconds
using DateTime::format. Every other unit of time can be added or subtracted.
Please consider adding:
decisecond
centisecond
millisecond
microsecond
Test script:
---------------
$time = new DateTime('01:01:01.000001');
$timeH = $time->modify('+1 hour');
echo $timeH->format('H:i:s.u') . '<br>'; // prints 02:01:01.000001
$timeM = $time->modify('+1 minute');
echo $timeM->format('H:i:s.u') . '<br>'; // prints 02:02:01.000001
$timeS = $time->modify('+1 second');
echo $timeS->format('H:i:s.u') . '<br>'; // prints 02:02:02.000001
$timeMS = $time->modify('+1 microsecond');
echo $timeMS->format('H:i:S:u') . '<br>'; // error
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64887&edit=1