|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-07-25 08:19 UTC] cataphract@php.net
[2012-07-25 08:19 UTC] cataphract@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cataphract
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 03:00:02 2025 UTC |
Description: ------------ The IntlDateFormatter and MessageFormatter class do not respect the date.timezone INI setting in PHP. They only honor the TZ environment setting. There is a workaround, which is calling the following line before using the date formatters for the first time: putenv('TZ=' . ini_get('date.timezone')); Reproduce code: --------------- <?php $time = 1247013673; putenv('TZ'); // unset TZ ini_set('date.timezone', 'America/New_York'); $fmt = new IntlDateFormatter('en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL); $msgf = new MessageFormatter('en_US', '{0,date,full} {0,time,full}'); echo "date: " . @date('l, F j, Y g:i:s A T', $time) . "\n"; echo "intl: " . $fmt->format($time) . "\n"; echo "msgf: " . $msgf->format(array($time)) . "\n"; echo "\n"; Expected result: ---------------- date: Tuesday, July 7, 2009 8:41:13 PM EDT intl: Tuesday, July 7, 2009 8:41:13 PM ET msgf: Tuesday, July 7, 2009 8:41:13 PM ET Actual result: -------------- date: Tuesday, July 7, 2009 8:41:13 PM EDT intl: Tuesday, July 7, 2009 7:41:13 PM GMT-05:00 msgf: Tuesday, July 7, 2009 7:41:13 PM GMT-05:00 (Notice that the IntlDateFormatter and MessageFormatter do not account for daylight time) using putenv('TZ=' . ini_get('date.timezone')); instead of putenv('TZ') causes the Expected Result to occur.