我正在尝试将datetimte转换为更短的内容,但是出现以下错误。


  警告:date_format()期望参数1为DateTime,字符串在...




$datetime = '2012-03-24 17:45:12';
$time = date_format($datetime, 'g:i A');
echo $time;


我在干什么?
谢谢。

最佳答案

尝试使用DateTime

$date = new DateTime("2012-03-24 17:45:12");
echo $date->format("g:i A");

关于php - 如何从mysql datetime列中回显转换后的时间格式,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22897701/

10-16 15:15