如何将Meetup API中的“时间”转换为可识别的格式?

http://www.meetup.com/meetup_api/docs/2/event/

这是Meetup API对时间的定义:

自纪元以来的事件开始时间(以毫秒为单位),或相对于d / w / m格式的当前时间。

这是我在JSON中看到的值的类型:

"time": 1382742000000, 

有关如何将其转换为可识别的东西的任何建议吗?

您可以构建这样的日期对象

 var date = new Date(milliseconds); 

然后,您可以使用Date属性应用任何所需的格式

试试这个

 // 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库可以帮到很好

片刻(1382742000000)会给你对象,你可以在里面看到:

2013年10月25日星期五19:00:00