I'm trying to get ALL existing timezone's abbreviations. [NSTimeZone abbreviationDictionary]
only returns some of them, but some like AEST (from Australia/Brisbane) do no appear.
I found out that with this code
NSDate *myDate = [NSDate date];
NSDateFormatter *f = [[NSDateFormatter alloc] init];
[f setDateStyle:NSDateFormatterLongStyle];
[f setTimeStyle:NSDateFormatterLongStyle];
[f setDateFormat:@"zzzz"];
NSArray *timeZoneNames = [NSTimeZone knownTimeZoneNames];
for (NSString *name1 in timeZoneNames)
{
NSTimeZone *tz = [NSTimeZone timeZoneWithName:name1];
[f setTimeZone:tz];
DLog(@"%@ = \"%@\" = %@", [tz abbreviation], name1, [f stringFromDate:myDate]);
}
I can get all available timezone abbreviated and full names such as:
EET = "Europe/Kiev" = Eastern European Standard Time
WET = "Europe/Lisbon" = Western European Standard Time
CET = "Europe/Ljubljana" = Central European Standard Time
GMT = "Europe/London" = Greenwich Mean Time
But the timezone names are locale-dependent (my current [[NSLocale currentLocale]localeIdentifier] is en_GB), so I get some results like:
GMT-4 = "America/New_York" = Eastern Daylight Time
GMT-4 = "America/Nipigon" = Eastern Daylight Time
GMT-8 = "America/Nome" = Alaska Daylight Time
GMT-2 = "America/Noronha" = Fernando de Noronha Standard Time
Is there a way I can get all the existing timezone abbreviations instead of GMT-X?
Any help is much appreciated :)
Thank you!
You don't get those abbreviations, because they're not standard. Apple, like most computer makers, uses the semi-official IANA time zone database. IANA does not consider "AEST" to be a standard abbreviation (in fact their australasia
file includes significant discussion on this exact question), so it's not included in iOS's time zone data.