我在显示值时遇到错误:
$thedate = $row2['date'];
echo $thedate;
在 php 中,数据库 ($thedate) 中的值是“2015-05-05 21:52:31.000”
如何格式化它以便能够将其作为字符串显示在 php 页面上?目前它显示错误“DateTime 类的对象无法转换为字符串”。
你有一个DateTime http://php.net/manual/en/class.datetime.php对象,所以你必须使用format() http://php.net/manual/en/datetime.format.php格式化您的输出,例如
echo $thedate->format("Y-m-d");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)