PHP按区域设置日期格式(分隔符、顺序而非文本)


PHP format date by locale (separators, order not text)

例如,2014年2月22日与2014年2日或2014年02月22日。

strftime已经需要一个固定的格式,而只是更改文本。

是否有可能(php 5.3-大型基础设施,尚未更新)使用setlocale并根据本地规范格式化日期?

$dt = new DateTime($datetime);
$formatter = new IntlDateFormatter($locale, IntlDateFormatter::SHORT, IntlDateFormatter::SHORT);
return $formatter->format($dt);

经过四处挖掘,这是我发现的最近的一个。