2011-12-17 80 views
1

我用下面的代码在我的网站上显示的博客文章的时间:如何将php中的时间转换为用户友好的文本?

strftime('%B %e, %Y',strtotime($row->date)) 

它返回以下字符串:

November 7, 2011 

我如何能适应上述代码显示(.. st,..nd,..rd,..th)在数字的末尾。因此,我可以显示日期为:

November 7th, 2011 

回答

3

您应该使用date()像这样:

echo date('F jS, Y',strtotime($row->date)); 
4

当使用date(),该S字符替换ST,第二,第三或日:

date("F jS, Y", strtotime($row->date))