在phoneGap
APIs
中有两个Geo-location
一个Accelerometer
而另一个time-stamp
都在onSuccess
方法Accelerometer
中返回time-stamp
} 1386115200
看起来像Geo-location
,但Wed Dec 04 2013 01:41:03 ..
中的geolocation
我正在使用api
geolocation
,当用户开始跟踪时,直到用户每30秒停止一次,我得到api
object
并推入JSON.stringify
并且在停止跟踪后,我将该对象放入此timestamp
函数中,以便2013-12-04T19:32:43.895Z
变为此1386115200
,那么如何将此格式转换回此{{1}},因为我需要此格式我的进一步处理步骤
答案 0 :(得分:2)
您可以使用时间字符串实例化新的Date
对象,然后将.getTime()
除以1000.
function convertTimestamp(sTime) {
return Math.round(new Date(sTime).getTime()/1000);
}