Bug #55743 [Nab]: date u - Microseconds (added in PHP 5.2.2)
Edit report at https://bugs.php.net/bug.php?id=55743&edit=1
ID: 55743
Updated by: salathe@php.net
Reported by: bugzilla33 at gmail dot com
Summary: date u - Microseconds (added in PHP 5.2.2)
Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: All
PHP Version: 5.4.0beta1
Block user comment: N
Private report: N
New Comment:
The "u" format character does work for date(), it always gives the correct answer
of "000000" for this function. As explained here and on the date() page, date()
itself works with whole seconds for the timestamp. If fractions of seconds are
needed, use the DateTime class.
Again, the document is correct since the "u" format character exists and does
output the number of milliseconds for a given timestamp. However, that number
will always be none since date() works with integers, i.e. whole seconds, only.
Previous Comments:
------------------------------------------------------------------------
[2012-08-02 14:03:28] jsuprock at gmail dot com
Hi, I've experienced this as well, but I do follow your explanation. However,
what is the reason for the documentation on this page still being incorrect?
http://us2.php.net/manual/en/function.date.php
It has been almost a year, and the page still suggests that the "u" formatter
will work with date().
Thank you,
John
------------------------------------------------------------------------
[2011-09-23 13:29:55] bjori@php.net
"Note:
Since this function only accepts integer timestamps the u format character is
only useful when using the date_format() function with user based timestamps
created with date_create()."
See http://php.net/date
------------------------------------------------------------------------
[2011-09-20 18:42:46] bugzilla33 at gmail dot com
Description:
------------
http://pl.php.net/manual/en/function.date.php
http://pl.php.net/manual/en/function.gmdate.php
Specification:
u - Microseconds (added in PHP 5.2.2) - Example: 654321
u formater do not works because second parameter (called timestamp) is int type
u formater will works if second parameter (called timestamp) is double (compatible with current int)
Please remove u formater useless or fix specyfication
or a better fix it int -> double (second parameter)
Test script:
---------------
<?=gmdate('u',12.13)?>
<?=date('u',12.13)?>
Expected result:
----------------
130000
130000
Actual result:
--------------
000000
000000
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55743&edit=1
Thread (5 messages)