0

I'm trying to create an application that will be able to run a js function at an exact time on different mobile devices - like down to the millisecond.

Since I can't be sure that all devices have the exact same time, I have to get it from another place.

I'm using Firebase and have tried using the serverTimeOffset to estimate the server time - but it is too inaccurate. Is there a way to get the exact time? It seems like calling a server is not the solution.

I have full access to the wifi network that the users will be connected to, and will also be able to e.g. set up a ble transmitter.

Does anyone have any insights or have worked with a similar project?

kstdk
  • 1
  • 1
  • Why would requesting `new Date()` or `new Date().getTime()` from the server not work? The server would give you its own time, that you can use as a reference across all devices. – Jeremy Thille Jun 10 '16 at 08:15
  • But new Date().getTime() is for client time, right? Also it needs to be very exact - there can't be a 0.25 second delay or anything – kstdk Jun 10 '16 at 08:18
  • You might find this useful http://stackoverflow.com/questions/8478179/synchronize-time-in-javascript-with-a-good-precision-0-5s-ntp-like I was looking at it for a project but it didn't go ahead. – Sudsy Jun 10 '16 at 08:19
  • Yeah sorry, `Date().getTime()` is javascript, it would work on a NodeJS server. But you can do the same in PHP or whatever. I believe matching the _exact_ international atomic-time to the microsecond is not that important. What you want is a reference 'beep' from the server, that all devices will receive at the same time. What I would do is just use [socket.io](http://socket.io/) and `socket.emit('beep')` to all clients. But even with this, they won't receive it _EXACTLY_ at the very same femtosecond, because you will always have network lag, slower device, etc. – Jeremy Thille Jun 10 '16 at 08:25
  • Gps relies on the reciever knowing exact time to measure distance to satellite from time of flight of the radio signals which include the time it was transmitted. but i am not familiar with mobile os services, does location service also provide the timestamp when the location was determined? – DisappointedByUnaccountableMod Jun 12 '16 at 13:02
  • Doesn't respond to answer... – DisappointedByUnaccountableMod Jun 20 '16 at 22:29
  • (Just got back from vacation) I actually have no idea if location service provides timestamp. Will look into that, thanks – kstdk Jun 27 '16 at 06:16

0 Answers0