简体   繁体   中英

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.

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

Your timestamp is in a miliseconds format. To get regular unix timestamp, divide it by 1000:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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