Symfony 2 在自己的 DateTimeToLocalizedStringTransformer 中使用 intlDateFormatter 但不能正常工作。
$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";
我有结果
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
我试试
pecl install timezonedb
pecl install intl
并重新安装 libicu44