Bug #74298 [Com]: IntlDateFormatter->format() doesn't return microseconds/fractions

[email protected] ("andrew dot nester dot dev at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=74298&edit=1

 ID:                 74298
 Comment by:         andrew dot nester dot dev at gmail dot com
 Reported by:        jh at ht-studios dot de
 Summary:            IntlDateFormatter->format() doesn't return
                     microseconds/fractions
 Status:             Open
 Type:               Bug
 Package:            *General Issues
 Operating System:   Ubuntu 16.04 (puphpet)
 PHP Version:        7.1.3
 Block user comment: N
 Private report:     N

 New Comment:

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)


Previous Comments:
------------------------------------------------------------------------
[2017-03-23 14:21:55] jh at ht-studios dot de

Description:
------------
PHP's IntlDateFormatter/IntlDateFormatter->format() returns zeros instead of Fractional Seconds: http://www.icu-project.org/apiref/icu4c/classSimpleDateFormat.html#details

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

Test script:
---------------
<?php
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(
    'en-US',
    \IntlDateFormatter::FULL,
    \IntlDateFormatter::FULL,
    'UTC',
    \IntlDateFormatter::GREGORIAN,
    'yyyy-MM-dd HH:mm:ss.SSSSSS'
))->format(new \DateTime()));

echo var_dump(datefmt_create(
    'en-US',
    \IntlDateFormatter::FULL,
    \IntlDateFormatter::FULL,
    'UTC',
    \IntlDateFormatter::GREGORIAN,
    'yyyy-MM-dd HH:mm:ss.SSSSSS'
)->format(new \DateTime()));


Expected result:
----------------
Microseconds should be outputted correctly.

Actual result:
--------------
Instead you get '000000`'

See: https://3v4l.org/3pMtR


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=74298&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.