将日期时间字段时间戳从mysql转换为php [英] Converting a datetime field timestamp from mysql to php
本文介绍了将日期时间字段时间戳从mysql转换为php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经阅读了有关如何执行此操作的信息,大多数人都提出了此解决方案.我只想显示时间格式.
I have read about how to do this and most come up with this solution. I just want to display the time format.
$starttime = "1899-12-30 06:52:47";
<?php echo date("h:i:s",strtotime($starttime)); ?>
由于某种原因,它返回"16:00:00"
For some reason this returns "16:00:00"
我在做什么错了?
推荐答案
如注释中所述,您的日期早于unix时代. DateTime()
可以解决此问题.
As mentioned in the comments your date is before the unix epoch. DateTime()
allows you to work around that.
$dt = new DateTime("1899-12-30 06:52:47");
echo $dt->format("h:i:s");
这篇关于将日期时间字段时间戳从mysql转换为php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文