Reputation: 4056
In phoneGap
there are two APIs
one is Geo-location
and other is Accelerometer
both return time-stamp
in onSuccess
method in Accelerometer
the time-stamp
is looks like this 1386115200
but in Geo-location
it gives like Wed Dec 04 2013 01:41:03 ..
I am using the geolocation
api
and when user start tracking then until user stops every 30 second i get geolocation
api
and push into object
and after stop tracking i put that object in this JSON.stringify
function so the timestamp
become like this 2013-12-04T19:32:43.895Z
so how to i convert back this format like this 1386115200
because i need this format for my further processing steps
Upvotes: 0
Views: 967
Reputation: 2153
You can instantiate a new Date
object with the time string that you have then divide the .getTime()
by 1000.
function convertTimestamp(sTime) {
return Math.round(new Date(sTime).getTime()/1000);
}
Upvotes: 2