[英]How do I convert the “time” from the Meetup API to a recognizable format?
http://www.meetup.com/meetup_api/docs/2/event/
这是Meetup API的时间定义:
事件开始时间(以纪元为单位),以毫秒为单位,或者相对于当前时间(以d / w / m格式)。
这是我在JSON中返回的值的类型:
"time": 1382742000000,
关于如何将其转换为可识别的内容的任何建议?
尝试这个
// 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;
moment.js库可以很好地帮助您
moment(1382742000000)将给您对象,并且在其中您可以看到:
2013年10月25日星期五19:00:00
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.