Edit report at https://bugs.php.net/bug.php?id=55743&edit=1

 ID:                 55743
 Comment by:         jsuprock at gmail dot com
 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:

Hi Salathe,

    I suspected that this was the case based on the API for date() at php.net 
and the NOTE section.  I'm not disagreeing, but my issue is mainly with the 
documentation... 

    So here's the part where I feel like I need to put in my 2 cents, and I do 
appreciate your ears regardless of the outcome.  (You have been great so far.)  
With respect to what the NOTE section states, it would probably make more sense 
to do the following:

  (1) Disable this formatting character for date() and gmdate(), and 
specifically remove the formatting character from the documentation on the 
date() page.

  (2) Update the DateTime::format() page with an explicit list of formatting 
characters including the "u".

After all, the "u" format character is completely useless in the context of 
date(), and it really should not be allowed at all.  I just think it causes 
more 
confusion is all...unless perhaps in the future all PHP date functions will 
accept microtime(true) (with a precision of 6) instead of time().

Sincerely,

John


Previous Comments:
------------------------------------------------------------------------
[2012-08-02 14:21:49] sala...@php.net

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.

------------------------------------------------------------------------
[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] bj...@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

Reply via email to