/Date(long + 1000)/ format

橙三吉。 提交于 2019-12-12 17:09:40

问题


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)\/" }

回答1:


you can just use the part before the +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)

so paste Date(1438218663000) in your browser console and you'll see

"Tue Oct 20 2015 21:27:39 GMT-0700 (Pacific Daylight Time)"

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) as a url. But in any case, it's just unix time.

EDIT: +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)



来源:https://stackoverflow.com/questions/33250878/datelong-1000-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!