Skip to content

How to correctly set Time zones

Zakaria Braksa edited this page Jul 24, 2015 · 8 revisions
  • This is just a little experiment to better illustrate how Traccar server having a time zone different than UTC can make things a mess.
  • The difference between the first and second setup is the time zone used by the Traccar Server.
  • Traccar server by the way inherits the system time zone (the server on which it's running when it it's daemon was launched)
  • In both examples the GPS tracker time zone is UTC+2, but it doesn't really matter, it could be anything else.
  • Also MySQL DB time zone in both examples is UTC+3, but it was intentional to illustrate that MySQL time zone has no effect.

Bad setup

  • GPS Tracker (UTC+2) -> Traccar server (UTC+1) -> MySQL (UTC+3) -> Rails (UTC)

Results

  • Time on the GPS Tracked was 21:18:37 UTC+2
  • In Traccar logs I got 20:18:37 UTC+1, which make sense, since clearly Traccar translated from UTC+2 to UTC+1
  • In MySQL I got 2015-07-24 20:18:37 (which is bad since it doesn't include any Timezone information)
  • And from the Rails console I get 20:18:37 UTC +00:00 (since MySQL doesn't keep time zone data with dates)

Good setup 👍

  • GPS Tracker (UTC+2) -> Traccar server (UTC) -> MySQL (UTC+3) -> Rails (UTC)

Results

  • Time on the GPS tracker was 21:06 UTC+2
  • From Traccar logs it showed up as 19:06 UTC (so clearly Traccar translated it to current system time which is UTC)
  • From MySQL database I got 19:06
  • From Rails console database it showed up as 19:06:00 UTC +00:00 (which is correct)

Conclusion

The computer/server on which Traccar server is running should be on UTC.

Clone this wiki locally