Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a database with location -> name of timezone as per IANA Time Zone Database [closed]

In my script (PHP), I use the tz database label for each location in my database: http://en.wikipedia.org/wiki/Tz_database

I am entering a whole series of places (countries, provinces, states, cities, etc.) from around the world, and for each, I have found it very difficult to know which label from the IANA Time Zone Database to use.

Searching the location on wikipedia gives me the time offset (UTC+n) and the timezone abbreviation (EST, etc.) but neither helps in knowing which entry to use in the tz database.

E.g.: Washington DC uses, as best as I could figure out, 'America/New_york'.
Dallas, TX uses 'America/Chicago' (unless I'm mistaken!)

There is a small African country for which neither its capital city nor its largest city were in the tz database. Which tz entry to use?

There must be a database somewhere, or a resource which clearly links every location on earth (country, state, province, city, etc.) to a specific entry in the tz database. Where can I find it?

like image 987
augustin Avatar asked May 21 '14 01:05

augustin


People also ask

What is the tz name from the IANA Time Zone Database?

The tz database is also known as tzdata, the zoneinfo database or IANA time zone database, and occasionally as the Olson database, referring to the founding contributor, Arthur David Olson.

Where are time zone data files stored?

DESCRIPTION top. The timezone information files used by tzset(3) are typically found under a directory with a name like /usr/share/zoneinfo. These files use the format described in Internet RFC 8536. Each file is a sequence of 8-bit bytes.

How do databases store time zones?

Oracle: Use the TIMESTAMP WITH TIME ZONE data type as this can store the timezone of UTC. SQL Server: Use the DATETIMEOFFSET data type, which can store the timezone of UTC. MySQL: Use the TIMESTAMP data type which can include a timezone component.

What does the TZ database contain data about?

The Time Zone Database (often called tz or zoneinfo) contains code and data that represent the history of local time for many representative locations around the globe. It is updated periodically to reflect changes made by political bodies to time zone boundaries, UTC offsets, and daylight-saving rules.


1 Answers

combining google map API works fine for example use below API to get location from address. address is "Mountain View, CA, US"

https://maps.googleapis.com/maps/api/geocode/json?address=Mountain+View,+CA,+US&key=YOUR_API_KEY

this URL returns JSON some thing like this

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Mountain View",
               "short_name" : "Mountain View",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santa Clara County",
               "short_name" : "Santa Clara County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "California",
               "short_name" : "CA",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "94043",
               "short_name" : "94043",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "Mountain View, CA 94043, USA",
         "geometry" : {
            "location" : {
               "lat" : 37.4224764,
               "lng" : -122.0842499
            },
            "location_type" : "GEOMETRIC_CENTER",
            "viewport" : {
               "northeast" : {
                  "lat" : 37.4238253802915,
                  "lng" : -122.0829009197085
               },
               "southwest" : {
                  "lat" : 37.4211274197085,
                  "lng" : -122.0855988802915
               }
            }
         },
         "place_id" : "ChIJ2eUgeAK6j4ARbn5u_wAGqWA",
         "types" : [ "street_address" ]
      }
   ],
   "status" : "OK"
}

and you can extract location from JSON and call location to time zone API.

API call sample:

 https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510&timestamp=1331161200&key=YOUR_API_KEY

that returns JSON like this

{
   "dstOffset" : 0,
   "rawOffset" : -28800,
   "status" : "OK",
   "timeZoneId" : "America/Los_Angeles",
   "timeZoneName" : "Pacific Standard Time"
}
like image 78
Mehdi Avatar answered Oct 04 '22 15:10

Mehdi