0

My app compares local device time against a UK based server time, the device time must always be within two minutes (give or take) of the server time.. We've recently gained new clients in different timezones, so this causes an issue, due to time difference... Should this be done server-side or could this be handled on device? If this could be handled on device, any ideas would be greatly appreciated.

flatwhite
  • 27
  • 4

1 Answers1

0

Normally you would generate a UNIX timestamp, these are timezone independent and can be encoded into any timezone you want. If you generate one on your server and one on your device, then it's just a simple case of getting the device to send a request to the server (e.g. HTTP GET) with it's timestamp and the server will compare the difference.

See https://stackoverflow.com/a/23062640/1928362 for more info on timestamps. If you let us know what programming language you are using (on the server side), then perhaps we can mock up some code for it.

In Android you can generate a Unix timestamp by doing the following:

long unixTime = System.currentTimeMillis() / 1000;
KillerKode
  • 957
  • 1
  • 12
  • 31