Bug #48225 [Com]: Microseconds output wrong in DateTime::format()
| From: | jmdoren at ok dot cl | Date: | Sun, 23 Jan 2011 15:20:32 +0000 |
| Subject: | Bug #48225 [Com]: Microseconds output wrong in DateTime::format() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-158110@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=48225&edit=1
ID: 48225
Comment by: jmdoren at ok dot cl
Reported by: knut dot urdalen at gmail dot com
Summary: Microseconds output wrong in DateTime::format()
Status: Assigned
Type: Bug
Package: Date/time related
Operating System: *
PHP Version: 5.*, 6CVS (2009-05-09)
Assigned To: derick
Block user comment: N
Private report: N
New Comment:
I have the same problem
my OS : Fedora release 14 (Laughlin)
my php Version: PHP 5.3.5 (cli) (built: Jan 22 2011 00:55:37)
in my php.ini date.timezone=America/Santiago
my script: <?php echo date( 'd-m-Y G:i:s,u' ); ?>
my results:
23-01-2011 8:34:18,000000
23-01-2011 8:34:18,000000
23-01-2011 8:34:19,000000
23-01-2011 8:34:20,000000
....
Previous Comments:
------------------------------------------------------------------------
[2009-05-10 17:38:56] jani@php.net
See also bug #45554 and bug #47312
------------------------------------------------------------------------
[2009-05-10 17:29:54] knut dot urdalen at gmail dot com
Description:
------------
The date()-function allow a 'u' format character in the formatting field
as of PHP 5.2.2. The DateTime::format() function point to the same
manual page for the formatting as the date() function and since DateTime
actually store microseconds internally (as mentioned by Derick
previously) I think it's a bug that it's not output correctly.
Reproduce code:
---------------
<?php
date_default_timezone_set('Europe/Oslo');
$datetime = new DateTime();
echo $datetime->format('Y-m-d H:i:s.u')."\n";
?>
Expected result:
----------------
The 'u' format character should output the microsecond that is
internally stored in the DateTime object upon creation.
Actual result:
--------------
The 'u' format character always resolve to 00000.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=48225&edit=1