hallahan / LeafletPlayback

This is a Leaflet plug-in that plays back points that have a time stamp synchronized to a clock.
http://leafletplayback.theoutpost.io
Other
482 stars 166 forks source link

Something I do not understand about timestamp #11

Closed aborruso closed 10 years ago

aborruso commented 10 years ago

Hi, I have forked your repository and starting from your demo I have built another demo with my data: http://aborruso.github.io/LeafletPlayback/

My time is around 1392155552 - 11 february 2014 http://wolfr.am/1qJpcZ1 - but in the timeline I read 17 Jan 1970. What's wrong in my data https://github.com/aborruso/LeafletPlayback/blob/master/data/demo/demo-tracks_andy.js?

Thank you very much,

Andrea

hallahan commented 10 years ago

Hi Andrea,

Looking in the console, I see:

var d = new Date(1392155542);
d.toString()
"Fri Jan 16 1970 18:42:35 GMT-0800 (Pacific Standard Time)"

It seems like you have gotten your timestamp in some strange way. In JavaScript, you can get a unix time stamp this way:

Now:

new Date().getTime()
1395122672295

Also, you can give Date strings as such:

new Date('2012-12-12 12:22:32').getTime()
1355343752000

Let me know if you have more questions.

aborruso commented 10 years ago

Hi @hallahan, in the readme file you write "array of UNIX timestamps". My GPX tracks contain time info in ISO 8601 format and I have converted these in batch in Unix time, that should be expressed in seconds. It seems that in javascript Unix time is in milliseconds.

Thank you,

Andrea