I am trying to get the time from GPS with Javascript, I've found the Geolocation API (https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API.
It give me a GeolocationPosition (https://developer.mozilla.org/en-US/docs/Web/API/GeolocationPosition). But, the GeolocationPosition.timestamp contain time info from the device. If I change the hours on it, the return change too.
I would like get the time from the GPS when I ask it. The goal is to do a kind of Chronometer on 2 devices (one for start, an other for end) but, then I do the difference. But to do that, I need to have exactly the same time on each.
I can see 2 ways of achieving this:
Use a third-party API to get the current time, irrespective of the user's machine's time. However, the options for such APIs appear to be limited and not well-backed. If the stakes are low, you can try one of these:
Get the user's time zone based on their GPS (see here for many options), then get the time from your server and convert as necessary. This will require a little back-end coding to provide the response and also making sure your server's date/time are always correct. But it's probably better than making your app depend on a third-party API that may be taken down at any time.
If you need code specific to React, please provide what you have so far.