php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41806 milliseconds in date function
Submitted: 2007-06-25 23:53 UTC Modified: 2007-07-12 19:04 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: lordi at msdi dot ca Assigned: derick (profile)
Status: Not a bug Package: Date/time related
PHP Version: 5.2.3 OS: FreeBSD 6.2-RELEASE
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: lordi at msdi dot ca
New email:
PHP Version: OS:

 

 [2007-06-25 23:53 UTC] lordi at msdi dot ca
Description:
------------
Hi,

the "u" parameters in the date function should return milliseconds, but it always returns zeros.

Reproduce code:
---------------
date_default_timezone_set('America/Montreal');
echo date ('H:i:s:u');

Expected result:
----------------
19:50:39:123456

Actual result:
--------------
19:50:39:000000

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-26 00:27 UTC] sniper@php.net
I think someone forgot to commit the part to the ext/date/lib/ side of things when adding 'u' format as I can't see anywhere where t->f would be set to anything but 0..
 [2007-07-12 19:04 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is correct, it states that the timestamp is an integer, and that it defaults to the value of "time()" in the documentation. time() does not return a float with fractions of a second:

http://no.php.net/date:
Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given. In other words, timestamp  is optional and defaults to the value of time().
 [2011-02-16 19:19 UTC] somemail at gmail dot com
The problem still exists (Debian, PHP 5.2.6-1), even though the example wasn't good enough.


Reproduce code:
---------------------------
echo date('H:i:s.u', microtime(true));
echo microtime(true);


Expected:
---------------------------
20:15:44.380000
1297880144.38


Actual:
---------------------------
20:15:44.000000
1297880144.38
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 02:01:28 2024 UTC