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

**URL:** https://discourse.processing.org/t/how-can-i-convert-local-time-with-long-lat-into-universal-time/10181
**Category:** Libraries
**Created:** [April 11, 2019, 8:50am UTC](https://discourse.processing.org/t/how-can-i-convert-local-time-with-long-lat-into-universal-time/10181 "2019-04-11T08:50:05Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![EvilDuck](https://avatars.discourse-cdn.com/v4/letter/e/f04885/32.png) [@EvilDuck](https://discourse.processing.org/u/EvilDuck)
#### Post date: [April 11, 2019, 8:50am UTC](https://discourse.processing.org/t/how-can-i-convert-local-time-with-long-lat-into-universal-time/10181/1 "2019-04-11T08:50:05Z")

</div>

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 …

---

<div class="post-metadata">

### Author: ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)
#### Post date: [April 11, 2019, 3:47pm UTC](https://discourse.processing.org/t/how-can-i-convert-local-time-with-long-lat-into-universal-time/10181/2 "2019-04-11T15:47:41Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [April 15, 2019, 11:44pm UTC](https://discourse.processing.org/t/how-can-i-convert-local-time-with-long-lat-into-universal-time/10181/3 "2019-04-15T23:44:13Z")

</div>

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](http://www.geonames.org/export/web-services.html)

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

> **[agap/llttz](https://github.com/agap/llttz)**
>
> The easy way to get java TimeZone from latitude/longitude - agap/llttz

---

<div class="post-metadata">

### Author: ![EvilDuck](https://avatars.discourse-cdn.com/v4/letter/e/f04885/32.png) [@EvilDuck](https://discourse.processing.org/u/EvilDuck)
#### Post date: [April 16, 2019, 7:17am UTC](https://discourse.processing.org/t/how-can-i-convert-local-time-with-long-lat-into-universal-time/10181/4 "2019-04-16T07:17:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![EvilDuck](https://avatars.discourse-cdn.com/v4/letter/e/f04885/32.png) [@EvilDuck](https://discourse.processing.org/u/EvilDuck)
#### Post date: [April 16, 2019, 7:33am UTC](https://discourse.processing.org/t/how-can-i-convert-local-time-with-long-lat-into-universal-time/10181/5 "2019-04-16T07:33:33Z")

</div>

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](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).

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [April 16, 2019, 5:05pm UTC](https://discourse.processing.org/t/how-can-i-convert-local-time-with-long-lat-into-universal-time/10181/6 "2019-04-16T17:05:25Z")

</div>

> [@EvilDuck](#):
>
> I have made my own solution, I made a png map based  
> on this […] Later I can put the code online

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:

> **[GitHub - evansiroky/timezone-boundary-builder: A tool to extract data from...](https://github.com/evansiroky/timezone-boundary-builder)**
>
> A tool to extract data from Open Street Map (OSM) to build the boundaries of the world's timezones. - GitHub - evansiroky/timezone-boundary-builder: A tool to extract data from Open Street Map ...

which is wrapped by this Java library:

> **[GitHub - RomanIakovlev/timeshape: Java library to find timezone based on geo...](https://github.com/RomanIakovlev/timeshape)**
>
> Java library to find timezone based on geo coordinates - GitHub - RomanIakovlev/timeshape: Java library to find timezone based on geo coordinates

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.
