PHP 的 DateTime 是否支持其他格式/语言环境?


Does PHP's DateTime support other formats/locales?

嗯,我想这个问题很明显。

如果我有:

$now = new DateTime();
print $now->format('l, M d');

我可以用其他语言输出该日期吗?

PHP的intl扩展具有用于此目的的IntlDateFormatter

$fmt = new IntlDateFormatter(
    'de-DE',
    IntlDateFormatter::FULL,
    IntlDateFormatter::FULL,
    'America/Los_Angeles',
    IntlDateFormatter::GREGORIAN
);
$date = new DateTime;
echo $fmt->format($date);