6

Is there any library (or even better, web service) available which can convert from a latitude/longitude into a time zone?

(Originally asked by Matt Sheppard on Stack Overflow)

1

2 Answers 2

5

I've written a small Java class to do this, with the data structure embedded in the code. If you want to avoid using a web service, and accuracy of 2km is good enough, and you're happy to assume that timezone boundaries don't change, then it could help.

https://github.com/drtimcooper/LatLongToTimezone

2
  • link is broken.
    – Michael
    Commented Oct 26, 2022 at 0:15
  • 1
    Thanx @Michael. Fixed.
    – Tim Cooper
    Commented Oct 27, 2022 at 2:34
3

Here are some that I found that you can try for your project.

Library

Timezone

A simple way to get accurate current and historical timezone information based on zone or latitude and longitude coordinates. This gem uses the tz database for historical timezone information. It also uses the geonames API for timezone latitude and longitude lookup.

This is an API for Ruby projects. I haven't try it, since I used web services from Google Time API or TimeZoneDB (see bellow for more detail on TimeZoneDB) for my own projects.

For other programming languages you can always search GitHub.com.

Web Service

TimeZoneDB

TimezoneDb provides simple RESTful interface API and returns structured XML or JSON responses. Our API converts latitude & longitude to time zone data. You also able to retrieve time zone information for a specific zone. You need to register a free API key to start using our services.

You can use TimeZoneDB API to get time zone information on geographical point, i.e. longitude/latitude or time zone name. Before you can use it on your own project, you will need to sign up for the free service and get an API key.

Given the longitude/latitude pair or time zone name, the API will response with:

I personally used TimeZoneDB and cached the response on my back-end server to be used by a mobile client application.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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