GPS position to Timezone

Alex picture Alex · Nov 30, 2011 · Viewed 16k times · Source

I'd like to know the local time where my user is sending his request from. Basically, is there such a thing as a function like this

var localTime = getLocalTime( lat, long );

I'm not sure if a simple division on the lat could work, since most of the countries don't have perfect geometric shapes.

Any help would be great. Any language is accepted. I'd like to avoid calling distant APIs.

Answer

Josh Hunt picture Josh Hunt · Dec 10, 2013

The Google Time Zone API seems to be what you're after. It, however does not have any free tier.

The Time Zone API provides time offset data for locations on the surface of the earth. Requesting the time zone information for a specific Latitude/Longitude pair will return the name of that time zone, the time offset from UTC, and the Daylight Savings offset.