mysql时间戳转换/格式化注意:遇到格式不正确的数值
在我的数据库中,我已将已发布"行设置为时间戳,但在尝试对其进行转换/格式化时收到此通知:
In my database I have set row "posted" as a timestamp but I get this notice when trying to convert/format it:
Notice: A non well formed numeric value encountered
代码:
$posted = date('d/m/Y H:i:s', $row['posted']);
echo $posted;
我做错了什么?
推荐答案
这意味着 date()
的第二个参数是整数,所以转换 $row['posted']
先打时间戳.
This means that the second parameter for date()
is expecting integer, so convert $row['posted']
to timestamp first.
试试
$posted = date('d/m/Y H:i:s', strtotime($row['posted']));
相关文章