|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-01-28 14:53 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2020-01-28 14:53 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 23:00:01 2025 UTC |
Description: ------------ IntlDateFormatter::formatObject() fails when date has timezone type 2. Type 1 and 3 work fine. IntlDateFormatter::format() also works fine. Test script: --------------- <?php declare(strict_types = 1); $typeOne = new DateTimeImmutable('today', new DateTimeZone('+0000')); $typeTwo = new DateTimeImmutable('today', new DateTimeZone('Z')); $typeThree = new DateTimeImmutable('today', new DateTimeZone('UTC')); $locale = 'en'; $format = 'd. MMMM'; foreach ([$typeOne, $typeTwo, $typeThree] as $date) { var_dump($date); $formatter = new IntlDateFormatter($locale, IntlDateFormatter::FULL, IntlDateFormatter::FULL, null, null, $format); var_dump($formatter->format($date)); var_dump(IntlDateFormatter::formatObject($date, $format, $locale)); echo "\n\n\n"; } Expected result: ---------------- object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2020-01-28 00:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } string(11) "28. January" string(11) "28. January" object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2020-01-28 00:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(1) "Z" } string(11) "28. January" string(11) "28. January" object(DateTimeImmutable)#3 (3) { ["date"]=> string(26) "2020-01-28 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } string(11) "28. January" string(11) "28. January" Actual result: -------------- object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2020-01-28 00:00:00.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } string(11) "28. January" string(11) "28. January" object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2020-01-28 00:00:00.000000" ["timezone_type"]=> int(2) ["timezone"]=> string(1) "Z" } string(11) "28. January" bool(false) object(DateTimeImmutable)#3 (3) { ["date"]=> string(26) "2020-01-28 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } string(11) "28. January" string(11) "28. January"