son*_*ool 22 php mysql unix-timestamp date-formatting
让我们说在我的mysql数据库中我有一个时间戳2013-09-30 01:16:06,让我们说这个变量是$ts.
如何输出这个以显示更像September 30th, 2013?
Jua*_*tés 48
$timestamp = "2013-09-30 01:16:06";
echo date("F jS, Y", strtotime($timestamp)); //September 30th, 2013
Run Code Online (Sandbox Code Playgroud)
注意使用S获取当天的英语序数后缀.
由于您已经在使用,strtotime如果您需要当前时间的人类可读数据,您可以使用关键字" now ",如下所示strtotime("now")
相关来源
Han*_*nky 18
使用strtotime()该字符串转换为Unix时间戳,然后使用date()功能就像要显示它.
echo date("F j, Y, g:i a",strtotime($ts));
Run Code Online (Sandbox Code Playgroud)
参考:
http://www.php.net/manual/en/function.strtotime.php
http://www.php.net/manual/en/function.date.php