0

Symfony 2 use a intlDateFormatter in own DateTimeToLocalizedStringTransformer but is not work correctly.

$tz = new DateTimeZone('Europe/Moscow');
$date = new DateTime('1 march', $tz);


echo "PHP: " . phpversion() . "<br/>\n";
echo "Intl: " . phpversion('intl') . "<br/>\n";
echo "<br/>\n";

echo "TZ: " . $tz->getName() . "<br/>\n";

echo "Native:<br/>\n";
echo $date->format('H:i:s d.m.Y');
echo "<br/>\n";


echo "Intl:<br/>\n";
$formatter = new IntlDateFormatter('RU_ru', IntlDateFormatter::FULL, IntlDateFormatter::FULL, $tz->getName());
echo $formatter->format($date);
echo "\n";

i have result

PHP: 5.3.22-1~dotdeb.0
Intl: PECL-2.0.1
TZ: Europe/Moscow

Native:
00:00:00 01.03.2013
Intl:
28 february 2013 23:00:00

i try

pecl install timezonedb
pecl install intl

and reinstall libicu44

versh23
  • 149
  • 2
  • 12

1 Answers1

1

I get this:

<?php
$tz = new DateTimeZone('UTC');
$date = new DateTime('1 march', $tz);

echo "ICU data version: ", INTL_ICU_DATA_VERSION, "\n";
$formatter = new IntlDateFormatter('RU_ru', IntlDateFormatter::FULL,
        IntlDateFormatter::FULL, "Europe/Moscow");
echo $formatter->format($date), "\n";
ICU data version: 4.4.0.1
пятница, 1 марта 2013 г. 3:00:00 Московское стандартное время

This is wrong as Moscow is now in UTC+4 the whole year. However, this is a fairly recent development (they abandoned DST only a couple of years ago), so the ICU data is too old to reflect this. If you test with a more recent version of ICU, you get the correct results:

ICU data version: 49.1
пятница, 1 марта 2013 г., 4:00:00 Московское стандартное время
Artefacto
  • 96,375
  • 17
  • 202
  • 225
  • so, how i can update ICU data? like this? http://userguide.icu-project.org/datetime/timezone#TOC-Updating-the-Time-Zone-Data or simple reinstall libicu with newest version ? libicu48 for example – versh23 Mar 09 '13 at 08:58
  • @user1747168 You can follow that procedure, but be warned that if your package manager manages libicu the data may get rewritten on an update. If you want to update ICU instead, you'll have to recompile the PHP intl extension (by reinstalling with pecl for instance). – Artefacto Mar 09 '13 at 15:55