Reputation: 41
NSTimeZone *timezone = [NSTimeZone systemTimeZone];
NSString *timeZoneAbberivation = [timezone abbreviation];
timeZoneAbberivation is printing like GMT+5:30 like that. But I need GMT+5:30 to be printed as IST. (IST is of India/Kolkatta).
Suppose if it is America/Newyork time zone, I need it as EST, etc.
Upvotes: 4
Views: 737
Reputation: 181
In Swift you can use this:
let zone = TimeZone.current.identifier
print(zone)
In Objective-C you can use this:
NSTimeZone* timeZone = [NSTimeZone timeZoneWithAbbreviation:@"IST"];
NSString* timeZoneName = [timeZone localizedName:NSTimeZoneNameStyleStandard
locale:[NSLocale currentLocale]];
NSLog(@"Name : %@", timeZoneName);
Upvotes: 0
Reputation: 6396
You can use an NSDateFormatter
. Look into the z
format argument which supplies the "short specific non-location format"
NSDateFormatter Date Formatting Table
Upvotes: 3