Reputation: 2227
I have retrieved a list of all the time zones using this function and storing them in an array :
timeZoneElements = [NSTimeZone knownTimeZoneNames] ;
I want to get the list of abbreviations , for example : GMT+1 … is there any easy and quick way to do that ?
Many thanks
Edit 1 : This solution shows the timezones like follows : Asia/Beirut … therefore i need to show instead the GMT+2 label ..
Upvotes: 0
Views: 1181
Reputation: 649
Try This,
NSMutableArray *timeZoneArray = [[NSMutableArray alloc] initWithArray:[NSTimeZone knownTimeZoneNames]];
NSMutableArray *abbreviationArray = [[NSMutableArray alloc] init];
for (int count=0; count < [timeZoneArray count]-1; count=count+1)
{
[abbreviationArray addObject:[[NSTimeZone timeZoneWithName:[timeZoneArray objectAtIndex:count]] abbreviation]];
}
NSLog(@"Abbreviation : %@",abbreviationArray);
Upvotes: 3