Question

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 ..

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top