mysql时间戳转换/格式化注意:遇到格式不正确的数值 [英] mysql timestamp conversion/formatting Notice: A non well formed numeric value encountered

查看:58
本文介绍了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']));

这篇关于mysql时间戳转换/格式化注意:遇到格式不正确的数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆