xref: /PHP-8.0/ext/intl/tests/bug74298.phpt (revision ded3d984)
1--TEST--
2Bug #74298 (IntlDateFormatter->format() doesn't return microseconds/fractions)
3--SKIPIF--
4<?php if (!extension_loaded('intl')) print 'skip'; ?>
5--FILE--
6<?php
7var_dump((new \DateTime('2017-01-01 01:02:03.123456'))->format('Y-m-d\TH:i:s.u'));
8
9var_dump((new \IntlDateFormatter(
10    'en-US',
11    \IntlDateFormatter::FULL,
12    \IntlDateFormatter::FULL,
13    'UTC',
14    \IntlDateFormatter::GREGORIAN,
15    'yyyy-MM-dd HH:mm:ss.SSSSSS'
16))->format(new \DateTime('2017-01-01 01:02:03.123456', new \DateTimeZone('UTC'))));
17
18var_dump(datefmt_create(
19    'en-US',
20    \IntlDateFormatter::FULL,
21    \IntlDateFormatter::FULL,
22    'UTC',
23    \IntlDateFormatter::GREGORIAN,
24    'yyyy-MM-dd HH:mm:ss.SSSSSS'
25)->format(new \DateTime('2017-01-01 01:02:03.123456', new \DateTimeZone('UTC'))));
26?>
27--EXPECT--
28string(26) "2017-01-01T01:02:03.123456"
29string(26) "2017-01-01 01:02:03.123000"
30string(26) "2017-01-01 01:02:03.123000"
31