OGeek|极客世界-中国程序员成长平台

标题: 没有 GMT 偏移量的 IOS 时区缩写。需要直接像IST,EST等 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 13:36
标题: 没有 GMT 偏移量的 IOS 时区缩写。需要直接像IST,EST等

 NSTimeZone *timezone = [NSTimeZone systemTimeZone];
 NSString *timeZoneAbberivation = [timezone abbreviation];

timeZoneAbberivation 像 GMT+5:30 那样打印。但我需要将 GMT+5:30 打印为 IST。 (IST 属于印度/加尔各答)。

假设如果是美国/纽约时区,我需要它作为 EST 等。



Best Answer-推荐答案


您可以使用 NSDateFormatter。查看提供“短特定非位置格式”的 z 格式参数

NSDateFormatter Date Formatting Table

关于没有 GMT 偏移量的 IOS 时区缩写。需要直接像IST,EST等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45327894/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4