How can I convert local time with long & lat into universal time?

How can I convert local time (with long & lat) into universal time, is there maybe a library for this? The problem seems be be very difficult to solve. I am searching the interwebs now for two days already but to no avail.

Thx in advance and sorry for in the case if its a stupid question …

I don’t know the answer off the top of my head, but if you google “convert latitude and longitude to timezone” you’ll find a ton of results. Maybe that would be a good place to start?

1 Like

What do you need it for, and how accurate do you need it to be?

You could use the geonames API: http://www.geonames.org/export/web-services.html

Or, if some errors are acceptable, you could use a Java library like llttz

1 Like

I have been googling this for two full days, I could not find a decent answer.

Thx, that was the answer I was looking for!
In the mean time I have made my own solution, I made a png map based
on this; https://www.cia.gov/LIBRARY/publications/the-world-factbook/graphics/ref_maps/physical/pdf/standard_time_zones_of_the_world.pdf

when I read the lat/long, I get the timezones.
The map is 5400 by 2761 pixels.

edit; I thought there was an error in my map, but its the data I compared with that was wrong …
Works fine!

Later I can put the code online, but first I want to be sure it works properly (still needs more testing).

Thanks so much for planning to share you solution with the forum! It sounds interesting and extremely helpful to share.

If you want a polygon-based solution (rather than a web api, or a pixel-based solution), you could also use something like this set of geometry built from OpenStreetMap:

which is wrapped by this Java library:

However this might be an industrial-strength solution that is overkill for your needs – I believe that it has a relatively big footprint and long load time.

1 Like