所以,如果我使用顺序后缀:格式化日期,该月的一天
<?php echo date_format($date, "j M Y") ?>
我得到以下格式的日期:1月5日1950年
不过,我要的是什么沿线:1950年1月5日
我会怎么去添加额外的th?
所以,如果我使用顺序后缀:格式化日期,该月的一天
<?php echo date_format($date, "j M Y") ?>
我得到以下格式的日期:1月5日1950年
不过,我要的是什么沿线:1950年1月5日
我会怎么去添加额外的th?
看看这里http://www.php.net/manual/en/function.date.php的格式,但
<?php echo date_format($date, "jS M Y") ?><br>
对于国际日期,我想你会做这样的事情:
$ordinal = new NumberFormatter($locale, NumberFormatter::ORDINAL);
$ordinal = $ordinal->format(date_format($date, "j"));
$pattern = "d'{$ordinal}' MMM yyyy";
$dateFormatter = new IntlDateFormatter($locale, IntlDateFormatter::FULL, IntlDateFormatter::FULL, $timezone, IntlDateFormatter::GREGORIAN);
$dateFormatter->setPattern($pattern);
$dateFormatter->format($date->getTimestamp());
以上是未经测试,但看起来它会工作。
echo date_format($date, "jS M Y");
只要检查documentation。
5秒钟在你正在使用的功能的手册页上将回答这个问题,但你只是**懒惰** –
PHP是我见过的最有说服力的语言之一,他们有一个官员该手册解释了该语言或其任何官方扩展中包含的每个功能,类别和方法的行为。快速查看日期()手册,你会得到你的答案。 – Havenard