php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64887 Add microseconds to DateTime::format
Submitted: 2013-05-21 07:09 UTC Modified: 2016-10-07 17:44 UTC
Votes:11
Avg. Score:4.1 ± 1.4
Reproduced:8 of 8 (100.0%)
Same Version:8 (100.0%)
Same OS:6 (75.0%)
From: glass at glasshalfawesome dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: Irrelevant OS: Win7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: glass at glasshalfawesome dot com
New email:
PHP Version: OS:

 

 [2013-05-21 07:09 UTC] 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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-07 17:44 UTC] derick@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: derick
 [2016-10-07 17:44 UTC] derick@php.net
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
 [2016-10-07 17:49 UTC] derick@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e3271b1814bd55901224a1cb3bc3fce00caa9bd5
Log: Fixed bug #64887 (Allow DateTime modification with subsecond items).
 [2016-10-17 10:07 UTC] bwoebi@php.net
Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e3271b1814bd55901224a1cb3bc3fce00caa9bd5
Log: Fixed bug #64887 (Allow DateTime modification with subsecond items).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC