IntlDateFormatter返回错误的模式

时间:2014-04-24 15:13:08

标签: php date internationalization

我第一次使用IntlDateFormatter / i18n。当我想用法语格式化日期时,我得到了正确的格式(dd / MM / yyyy)但是当我正在寻找意大利语格式(例如)时,我得到了错误的格式(dd / MM / yy)而不是和法国人一样。

这是IntlDateFormatter的错误吗?我做错了吗? 这是一个代码示例:

<?php
$fmt = new IntlDateFormatter('fr_FR', IntlDateFormatter::SHORT, IntlDateFormatter::NONE);
echo $fmt->getPattern();  // return dd/MM/yyyy

$fmt = new IntlDateFormatter('it_IT', IntlDateFormatter::SHORT, IntlDateFormatter::NONE);
echo $fmt->getPattern();  // return dd/MM/yy instead of dd/MM/yyyy

以下是我提取信息的地方for the date format in France and Italyfor the IntlDateFormatter patterns

1 个答案:

答案 0 :(得分:0)

对于我来说,使用php5.5和lib-icu 4.2.1这两个国家都给我dd / MM / yy,所以如果你想要一个不同的模式,我建议你在上游创建一个数组并使用你的调用setPattern。

我想问题来自您系统中的libicu版本,但我不是百分百肯定。