Question

If I want to get the time zone for a specific location I could search in the array:

NSArray * timeZoneNames = [NSTimeZone knownTimeZoneNames];

But what if the timezone for a specific place that has no representation in this list? What can I do than?

For example if I search for 'Munich' but actually wanted to have the correct timezone which is 'Europe/Berlin'?

I haven't found any answer for this problem.

Was it helpful?

Solution

You can use geocoding to find the location of a city as a latitude/longitude:

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/LocationAwarenessPG/UsingGeocoders/UsingGeocoders.html

The coordinates for each timezone is available under CC-0 license (effectively public domain) from this website:

http://efele.net/maps/tz/world/

So basically, embed the timezone database in your app, then use Apple's service to geocode the city name, then check which timezone contains the coordinates for the city.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top