【发布时间】:2019-10-26 22:53:47
【问题描述】:
我在 MySQL 数据库中有一个列,它是 DATETIME 数据类型,其默认值为 CURRENT_TIMESTAMP。我正在尝试使用 PHP 的 date_format() 函数对其进行格式化,这给了我以下错误
警告:date_format() 期望参数 1 为 DateTimeInterface, C:\wamp64\www\cms\CMS_TEMPLATE\includes\content.php 中给出的字符串 第 26 行
$stmt = $connect->link->query("SELECT post_date FROM posts");
while($row = $stmt->fetch()){
$date = $row["post_date"];
echo date_format($date,'d/F/Y g:i A');
}
我应该使用不同的函数还是只是语法错误?
【问题讨论】: