我有一个时间戳,如2014-05-26 16:39:32。从这个时间戳我想做点什么,下午4:39,2014年5月26日。这里面有什么内置功能吗?或者怎么做呢?
try
echo date('h:i A, dS M Y', strtotime('2014-05-26 16:39:32')); // 04:39 PM, 26th May 2014
没有前导零的时间尝试4:39
echo date('g:i A,dS M Y', strtotime('2014-05-26 16:39:32')); // 4:39 PM, 26th May 2014
更多信息请阅读手册:- http://php.net/manual/en/function.date.php
echo date('g:i A,dS M Y',strtotime('2014-05-26 16:39:32'));
更多信息可以参考php中的date函数
像这样使用 DateTime
类
$a = new DateTime("2014-05-26 16:39:32");
echo $a->format("h:i A, dS M Y");