Mobile App: how to get correct time when offline
<p>We're building an App using Ionic/cordova that will need to run on Android, iOS and Windows 10 Mobile.</p>

<p>The goal is to register start and stop events, we'll need the exact time and location when this events are registered.</p>

<p>There is a serious concern that the users will modify the timesettings on their phone to send false data.</p>

<p>As long as these events are sent immediately to the server, we can use the server time to validate what the user is sending us. But there is also a requirement to be able to work when offline.</p>

<p>Our first thought was to use the GPS time. In cordova the position object has a timestamp.
<a href="https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-geolocation/" rel="nofollow noreferrer">https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-geolocation/</a></p>

<p>But after further reading, <a href="https://stackoverflow.com/questions/1444456/is-it-possible-to-get-the-atomic-clock-timestamp-from-the-iphone-gps">here</a> and <a href="https://stackoverflow.com/questions/8210264/sync-android-devices-via-gps-time">here</a>, that this isn't necessarily the time of the GPS server but also just the local time. I've read about work arounds using the uptime of the device, but this won't work as soon as there is a reboot. But most of these conversations are a few years old.</p>

<p>For now we think the simples approach will be to flag events that are sent offline as 'suspicious'.</p>

<p>Is there any other way to accurately determine the time when you're offline without risk that the user tampered with it?</p>