Reputation: 1864
In my app I have a date and place value which I would like to add the appropriate timezone.
What I have now:
14 Feb 2014 - 11:45 from Munich
or 14 Feb 2014 - 15:05 to New York
I would like to change it to:
14 Feb 2014 - 11:45 AM GMT+1 from Munich
or 14 Feb 2014 - 3:05 PM EST to New York
Is there any way I can find out the timezone for the date and place?
Thanks a lot!
Upvotes: 1
Views: 193
Reputation: 241475
Since you said the locations are fixed in your app, you should simply assign each of your locations to an actual IANA time zone identifier to start with.
For example, Munich would be covered by the Europe/Berlin
time zone, and New York is (of course) in America/New_York
. You can review the list here.
Now that you know the time zone for the location, you can easily determine the offset for the local time, or get an abbreviation. You can use the NSTimeZone
class for that. The reference is here.
If you get an abbreviation, make sure you understand that time zone abbreviations are for display only. You can show them to a user, but there is too much ambiguity to correlate an abbreviation like EST or CST back to a particular time zone.
Upvotes: 3