We have an NSTimeZone class that talks more about the time zone. But I want to get only the time offset. For example: +05.30 offset for Inida In other words, the time offset with reference to UTC.
One problem with the following code is that it crashes with 4.3 simulator and works great with 4.2 simulator. Since 4.2 simulator gives output with reference to GMT simulator and 4.3 with reference to IST
NSString* tzDescription = [[NSTimeZone systemTimeZone] description]; NSArray* tzArray = [tzDescription componentsSeparatedByString:@"GMT"]; NSString* gmtStr = [[tzArray objectAtIndex:1] substringToIndex:6];
I could not find a solution that is generic.
source share