I have a uBlox NEO-6M GPS module and it is outputting longitude and latitude. It is also outputting time which is UTC. I want to use the GPS coordinates to calculate the timezone and then subtract and add hours based on that. Is it possible in any way? I know I can do this using WiFi but I want to use GPS to do it.

  • Normally you would really use an internally saved map for getting the timezone. But it might not be easy to save a detailed map of the timezones. Memory is rather rare. But you could make some compromises and make an easier representation of the timezones (maybe using the longitude as the main value, having an array of the longitudes of the timezone limits, then some if statements for special cases, where the same longitude has multiple timezones). That will not always work, since timezones can be complex in detail, but it will be good in most cases – chrisl Feb 23 at 20:22
  • Is there some example code as that sounds fairly complex? – DragonflyRobotics Feb 23 at 20:37
  • I doubt you will be able to fit a timezone shapefile in your Arduino's memory. If you want to try anyway, take a look at these discussions and the offline resources listed in this answer. For some background, see also The Problem with Time & Timezones. – Edgar Bonet Feb 23 at 20:53
  • Out from experience, even professional GPS devices with embedded maps often get that wrong. I was sailing from Germany to Bornholm last summer, when my $800 GPS of a namely vendor set the time zone to east european time. Even by simple 15° time zones, one would be better than that... – PMF Feb 24 at 21:12

Timezones are political constructs, same as summer/winter time switch rules. You'd need a map to look up the country/region and its current local time zone.

Your commercial car satnav is probably/perhaps equipped with such map information.

  • I want to calculate it using Arduino and a GPS. I know what a time zone is but I need to know it so that I can have the right time if I am in a different region. I cannot hook the Arduino to anything because it is a homemade watch. – DragonflyRobotics Feb 23 at 19:47
  • 3
    You can't calculate it. You could look it up on a map you store in arduino. Good luck. – DataFiddler Feb 23 at 19:59
  • Yes, sorry, by calculate, I meant lookup. – DragonflyRobotics Feb 23 at 20:28
  • So is there a way to store a map on an Arduino. I have an Arduino Nano 33 IOT. – DragonflyRobotics Feb 23 at 20:29
  • If the border between two time zones is a simple line consisting of an ordered list of points (more or less in North-South direction) you can easily calculate if your location is East or West of that border. (by linear interpolation) That's a simple special case of the general question whether a point is inside a given area or not. All that math is not arduino specific. Storing the points of those border lines is a bit tedious, but simple. – DataFiddler Feb 23 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.