问题
http://www.meetup.com/meetup_api/docs/2/event/
Here's the Meetup API's definition of time:
Event start time in milliseconds since the epoch, or relative to the current time in the d/w/m format.
Here's the type of value I see returned in the JSON:
"time": 1382742000000,
Any advice about how to convert it into something recognizable?
回答1:
You can construct a date object like this
var date = new Date(milliseconds);
And then you could apply any format you want using Date properties
回答2:
Try this
// Convert milliseconds since since 00:00:00 UTC, Thursday, 1 January 1970 (the epoch in Unix speak)
var date = new Date(1382742000000);
// now get individual properties from the date object to construct a new format
// hours part from the timestamp
var hours = date.getHours();
// minutes part from the timestamp
var minutes = date.getMinutes();
// seconds part from the timestamp
var seconds = date.getSeconds();
// display time in our new format
var formattedTime = hours + ':' + minutes + ':' + seconds;
回答3:
moment.js library can help very well
moment(1382742000000) will give you object and inside of it you can see:
Fri Oct 25 2013 19:00:00
来源:https://stackoverflow.com/questions/19596875/how-do-i-convert-the-time-from-the-meetup-api-to-a-recognizable-format