显示错误日期的时间戳 UTC 抛出了 PHP 日期函数


Time UTC stamp displaying wrong Date threw PHP date function

我正在将下面的函数用于 UTC 时间戳到日期的对话,但它给了我错误的答案。

echo  date('Y-m-d H:i:s',1379658966473);

它给我回报

45689-08-26 01:47:53

但实际上答案是

GMT: Fri, 20 Sep 2013 06:36:06 GMT
Your time zone: 20 September 2013 12:06:06 PM GMT+5.5

我从 http://www.epochconverter.com/在线转换器网站得到的,它做对了

时间戳采用毫秒格式。要获得常规的 unix 时间戳,请将其除以 1000:

$timestamp = 1379658966473 / 1000;
echo  date('Y-m-d H:i:s', $timestamp);

你的时间戳是微时间的,日期函数需要一个简单的时间戳,你需要使用 time() 函数而不是微时间()