【发布时间】:2011-12-17 16:47:36
【问题描述】:
我使用以下代码在我的网站上显示博客文章的时间:
strftime('%B %e, %Y',strtotime($row->date))
返回以下字符串:
November 7, 2011
如何调整上述代码以在数字末尾显示 (..st, ..nd, ..rd, ..th)。所以我可以将日期显示为:
November 7th, 2011
等等
【问题讨论】:
我使用以下代码在我的网站上显示博客文章的时间:
strftime('%B %e, %Y',strtotime($row->date))
返回以下字符串:
November 7, 2011
如何调整上述代码以在数字末尾显示 (..st, ..nd, ..rd, ..th)。所以我可以将日期显示为:
November 7th, 2011
等等
【问题讨论】:
使用date() 时,S 字符被替换为 st、nd、rd 或 th:
date("F jS, Y", strtotime($row->date))
【讨论】:
你应该像这样使用date():
echo date('F jS, Y',strtotime($row->date));
【讨论】: