简体   繁体   English

时间UTC戳显示错误日期投掷PHP日期功能

[英]Time UTC stamp displaying wrong Date threw PHP date function

I am using this below function for utc timestamp to date conversation but its giving me wrong answer. 我正在使用以下函数来进行utc时间戳记对话,但它给出了错误的答案。

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

Its give me in returns 它给了我回报

45689-08-26 01:47:53

But actually answer is 但实际答案是

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

which i got from http://www.epochconverter.com/ online converter website which is doing right 我是从http://www.epochconverter.com/在线转换器网站获得的,这是正确的

Your timestamp is in a miliseconds format. 您的时间戳是以毫秒为单位的格式。 To get regular unix timestamp, divide it by 1000: 要获得常规的unix时间戳,请将其除以1000:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM