问题
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