Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GPS position to Timezone

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.

like image 314
Alex Avatar asked Nov 30 '11 14:11

Alex


People also ask

How do you calculate time zone using latitude and longitude?

Here's how longitude converts into your personal time zone: 15 degrees of longitude = 1 hour difference; 1 degree longitude = 4 minutes difference. 15 minutes of longitude = 1 minute difference; 1 minute of longitude = 4 seconds difference.

Are time zones based on longitude?

Time zones are another arbitrary societal choice, like the origin point of the Prime Meridian. They are based on longitude and defined by Earth's rotation, which completes a full circle (360 degrees) each day (24 hours). Each hour then, Earth rotates through 360/24 = 15° of longitude: the width of one time zone.


1 Answers

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.

like image 112
Josh Hunt Avatar answered Mar 24 '23 04:03

Josh Hunt