【问题标题】:NSTimeZone timeZoneWithName abbreviation shows different Abbreviations on different devicesNSTimeZone timeZoneWithName 缩写在不同的设备上显示不同的缩写
【发布时间】:2015-04-23 07:12:11
【问题描述】:

我想在标签上显示“EDT”。我使用了下面的行,我发现它可以在 iphone6、6+ 和 iphone4 (iOS 7.1) 上运行。但是在 iPhone5s(iOS 8.2)、iPhone5(iOS 7.1) 上测试它我注意到它显示“GMT-4”

NSString *labelString = [NSString stringWithFormat:@"%@",[[NSTimeZone timeZoneWithName:@"America/New_York"] abbreviation]]

是与设备时区相关的问题还是有人可以指出我在哪里犯了错误。提前致谢。

【问题讨论】:

    标签: ios nsdateformatter nstimezone


    【解决方案1】:

    这是因为设备上设置了时区。不同的设备设置了不同的时区,这在

    [[NSTimeZone timeZoneWithName:@"America/New_York"] abbreviation]]
    

    【讨论】:

    • 这与您在问题中使用的有什么不同?在这两种情况下看起来都像 [[NSTimeZone timeZoneWithName:@"America/New_York"] abbreviation]]
    • 在一个设备设置系统时区是英国和另一个孟买。所以 [[NSTimeZone timeZoneWithName:@"America/New_York"] abbreviation]] 相应计算并带来不同的时区缩写。
    • @TomHarrington 我刚刚将所有设备上的系统时区更改为 IST,所有设备上的时区缩写都相同。
    猜你喜欢
    • 2013-12-06
    • 2013-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-30
    • 2015-12-31
    • 1970-01-01
    相关资源
    最近更新 更多