[英]How to show month name using PHP_intl?
我不斷得到數字而不是月份名稱。 我需要得到像July這樣的月份名稱。
$formatter = new \IntlDateFormatter(
"fa_IR@calendar=persian",
\IntlDateFormatter::FULL,
\IntlDateFormatter::FULL,
'Asia/Tehran',
\IntlDateFormatter::TRADITIONAL
);
$time = new \DateTime();
$formatter->setPattern('yyyy mm dd');
$formatter->format($time)
$time = new \DateTime();
$formatter->setPattern('yyyy MMMM dd');
$formatter->format($time)
使用 MMMM 顯示月份名稱。 更多信息: http : //userguide.icu-project.org/formatparse/datetime
$formatter->setPattern('yyyy MMMM dd');
更多信息: http : //userguide.icu-project.org/formatparse/datetime
試試這個:
setlocale(LC_ALL, 'no_NB.utf-8', 'nor'); // For other stuff
Locale::setDefault('no_NB.utf-8'); // For IntlDateFormatter
$f = new IntlDateFormatter(null, null, null, null, null, 'd. MMMM y');
echo "Date-". $f->format(new DateTime("2017-10-24"))."<br/>";
$f = new IntlDateFormatter(null, null, null, null, null, 'MMMM');
echo "Month-". $f->format(new DateTime("2017-10-24"));
輸出:
日期 - 2017 年 10 月 24 日
月份 - 十月
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.