php 将 YYYY-MM-DD 日期转换为文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7356092/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Convert YYYY-MM-DD date to text
提问by adamzwakk
Possible Duplicate:
Numerical Date To Text Date PHP
可能的重复:
数字日期到文本日期 PHP
I'm trying to find a way to convert a date to a more "user-friendly" format.
我试图找到一种方法将日期转换为更“用户友好”的格式。
For example, from 2011-01-05 to Jan 5th, 2011.
例如,从 2011-01-05 到 2011 年 1 月 5 日。
I'm sure it's something simple, I just can't seem to find it anywhere. Any ideas?
我确定这很简单,我似乎无法在任何地方找到它。有任何想法吗?
回答by Lawrence Cherone
For the thadd the English ordinal Suffix for the day of the month
为月份中的某一天th添加英文序数S后缀
date("M jS, Y", strtotime("2011-01-05"));
回答by Ben
Try this:
尝试这个:
date("M j, Y", strtotime("2011-01-05"));
回答by dersam
You could use the DateTimeclass, and call the format function. Then just set up the format using the standard date()format string to output a textual data format.
您可以使用DateTime该类,并调用格式函数。然后只需使用标准date()格式字符串设置格式即可输出文本数据格式。

