/日期(长+ 1000)/格式 [英] /Date(long + 1000)/ format
问题描述
有人知道它是什么类型的日期格式,如何将其正确解析为Date对象?我是在Jason响应中从服务器获得的.
does anyone know what type of date format is it, and how can I parse it properly to Date object? I get it from server in a Jason response.
{ "DateFirstListed":"\/Date(1438218663000+1000)\/" }
推荐答案
您可以只使用+1000之前的部分
you can just use the part before the +1000
这是标准的unix时间戳,以毫秒为单位.我不确定+1000是什么意思,但可能只是将时间偏移1秒. (1000毫秒)
it's a standard unix time stamp with milliseconds. I'm not sure what the +1000 is for but likely it's just to offset the time by 1 second. (1000 ms)
因此将Date(1438218663000)
粘贴到浏览器控制台中,您将看到
so paste Date(1438218663000)
in your browser console and you'll see
"Tue Oct 20 2015 21:27:39 GMT-0700 (Pacific Daylight Time)"
该URL可能旨在成为人类友好的URL,以便可以将其存储在Unix时间中,但是您可以使用
It could possibly be intended to be a Human Friendly url so that it can be stored in unix time, but you can use
/articles/Tue Oct 20 2015 21:27:39 GMT-0700 (Pacific Daylight Time)
作为网址.但是无论如何,这只是Unix时间.
/articles/Tue Oct 20 2015 21:27:39 GMT-0700 (Pacific Daylight Time)
as a url. But in any case, it's just unix time.
+1000(感谢Sasha)可能表示UTC + 10:00,因此您可以像这样创建日期
+1000 (thanks Sasha) probably means UTC+10:00, so you could create your date like this
new Date(new Date(1438218663000).getTime()+10*60*60*1000)
这篇关于/日期(长+ 1000)/格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!