gpt4 book ai didi

ios - iOS:我应该使用EST或EDT,为什么?

转载 作者:行者123 更新时间:2023-12-01 17:30:07 24 4
gpt4 key购买 nike

我不久前问了一个有关时区的问题,当时我正在使用EST。用户建议我使用EDT。我想知道为什么要使用一个或另一个,因为它们都为我同时打印。这里的代码可以更好地说明我的意思。

NSDate *today = [NSDate date];
NSDateFormatter *edtDf = [[NSDateFormatter alloc] init];
[edtDf setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"EDT"]];
[edtDf setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

NSString *stringDate = [edtDf stringFromDate:today];

NSLog(@"The EDT is %@", stringDate);

NSDate *today1 = [NSDate date];
NSDateFormatter *estDf = [[NSDateFormatter alloc] init];
[estDf setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"EST"]];
[estDf setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

NSString *stringDate1 = [estDf stringFromDate:today1];

NSLog(@"The EST is %@", stringDate1);

最佳答案

他们可能会根据一年中的时间打印不同的内容(因为一年中的时间确定夏令时是否处于 Activity 状态)。

不要使用EST EDT。使用US/EasternAmerica/New_York:

NSTimeZone *tz = [NSTimeZone timeZoneWithName:@"US/Eastern"];
// or
NSTimeZone *tz = [NSTimeZone timeZoneWithName:@"America/New_York"];

这些时区会在一年中的正确时间调整夏令时。

关于ios - iOS:我应该使用EST或EDT,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28954253/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com