php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58756 IntlDateFormatter and MessageFormatter do not respect date.timezone INI setting
Submitted: 2009-07-07 21:56 UTC Modified: 2012-07-25 08:19 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (100.0%)
From: kminkler at synacor dot com Assigned: cataphract (profile)
Status: Closed Package: intl (PECL)
PHP Version: 5.2.8 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kminkler at synacor dot com
New email:
PHP Version: OS:

 

 [2009-07-07 21:56 UTC] kminkler at synacor dot com
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-25 08:19 UTC] cataphract@php.net
This has fixed to the extent possible. This cannot be fixed for complex formats. 
See http://bugs.icu-project.org/trac/ticket/9330
 [2012-07-25 08:19 UTC] cataphract@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cataphract
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 19:01:30 2024 UTC