|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74298 IntlDateFormatter->format() doesn't return microseconds/fractions
Submitted: 2017-03-23 14:21 UTC Modified: 2017-03-25 11:23 UTC
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: jh at ht-studios dot de Assigned:
Status: Closed Package: intl (PECL)
PHP Version: 7.1.3 OS: Ubuntu 16.04 (puphpet)
Private report: No CVE-ID: None
 [2017-03-23 14:21 UTC] jh at ht-studios dot de
PHP's IntlDateFormatter/IntlDateFormatter->format() returns zeros instead of Fractional Seconds:

$ aptitude search '~i icu'
i A libicu52             - International Components for Unicode

Test script:
echo "All 3 should show the fractions of second:\n";

echo var_dump((new \DateTime())->format('Y-m-d\TH:i:s.u'));

echo var_dump((new \IntlDateFormatter(
    'yyyy-MM-dd HH:mm:ss.SSSSSS'
))->format(new \DateTime()));

echo var_dump(datefmt_create(
    'yyyy-MM-dd HH:mm:ss.SSSSSS'
)->format(new \DateTime()));

Expected result:
Microseconds should be outputted correctly.

Actual result:
Instead you get '000000`'



Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-24 16:28 UTC] andrew dot nester dot dev at gmail dot com
Thanks for pointing the issue! I just added PR for it.
To clarify a little bit - as documentation after you link says:

"Appends zeros if more than 3 letters specified. Truncates at three significant digits when parsing."
So it's possible to show only milliseconds (3 digits of fraction)
 [2017-03-25 11:23 UTC]
-Package: *General Issues +Package: intl
 [2017-04-09 10:57 UTC]
Automatic comment on behalf of
Log: Fixed #74298 - IntlDateFormatter-&gt;format() doesn't return microseconds/fractions
 [2017-04-09 10:57 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Sep 23 12:01:27 2023 UTC