PHP转换时间到目前为止 [英] PHP convert time to date
本文介绍了PHP转换时间到目前为止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的日期价值如此 1369195200000
,我试图将它转换为日期如此
I have date value like so 1369195200000
and I tried to convert it to date like so
$date = 1369195200000;
$result = date("Y-m-d", $date);
但它返回如此 45358-01-25
明年是错的....有没有得到正确的一年? $ date
来自数据库。
but it returns like so 45358-01-25
obviously the year is wrong....is there away to get the correct year? The $date
is coming from a database.
推荐答案
时间是以毫秒为单位,需要除以1000。
The time is in milliseconds, it needs to be divided by 1000.
$date = 1369195200000;
$result = date("Y-m-d", $date / 1000);
这篇关于PHP转换时间到目前为止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文