NSTimeZone *timezone = [NSTimeZone systemTimeZone];
NSString *timeZoneAbberivation = [timezone abbreviation];
timezoneone打印像GMT + 5:30那样。但我需要GMT + 5:30作为IST印刷。 (IST是印度/ Kolkatta)。没有GMT偏移量的IOS时区缩写。需要直接像IST,美国东部时间等
假设,如果它是美国/纽约时区,我需要它作为EST等
NSTimeZone *timezone = [NSTimeZone systemTimeZone];
NSString *timeZoneAbberivation = [timezone abbreviation];
timezoneone打印像GMT + 5:30那样。但我需要GMT + 5:30作为IST印刷。 (IST是印度/ Kolkatta)。没有GMT偏移量的IOS时区缩写。需要直接像IST,美国东部时间等
假设,如果它是美国/纽约时区,我需要它作为EST等
您可以使用NSDateFormatter
。看看它提供了 “短特定非定位格式”
在斯威夫特,你可以用这个z
format参数:
let zone = TimeZone.current.identifier
print(zone)
在Objective-C,你可以使用这个:
NSTimeZone* timeZone = [NSTimeZone timeZoneWithAbbreviation:@"IST"];
NSString* timeZoneName = [timeZone localizedName:NSTimeZoneNameStyleStandard
locale:[NSLocale currentLocale]];
NSLog(@"Name : %@", timeZoneName);
这不是你从'timeZone.name'得到的吗? – Sulthan
你试过把查找放在一起吗?应该是相当标准的! – Gyan