PHP的DateTime是否支持其他格式/区域设置?

Pet*_*ter 1 php date

好吧,我猜这个问题非常明显.

如果我有:

$now = new DateTime();
print $now->format('l, M d');
Run Code Online (Sandbox Code Playgroud)

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

dec*_*eze 6

PHP的intl扩展具有IntlDateFormatter此目的.

$fmt = new IntlDateFormatter(
    'de-DE',
    IntlDateFormatter::FULL,
    IntlDateFormatter::FULL,
    'America/Los_Angeles',
    IntlDateFormatter::GREGORIAN
);

$date = new DateTime;
echo $fmt->format($date);
Run Code Online (Sandbox Code Playgroud)