私には2つの変数があります:
NSTimeZone *timeZoneMinus5 = [NSTimeZone timeZoneForSecondsFromGMT: -18000];
NSTimeZone *timeZoneEST = [NSTimeZone timeZoneWithName:@"EST"];
デバイスとシミュレータでテストされ、両方とも戻りGMT-05:00
ます。
私がこれを書いているので、時間は2:55 am (GMT)
です。私は東部標準時のタイムゾーンにいるので、10:55pm (GMT-05:00)
2011年4月15日の夏時間を観察しています。
ただし、[timeZoneEST isDaylightSavingTime]
戻り値NO
と[timeZoneEST daylightSavingTimeOffset]
戻り値0
。
timeZoneEST
現在の時刻を文字列として取得するために使用する場合:
NSDate *gmtTime = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"h:mm a (z)"];
[dateFormatter setTimeZone: timeZoneEST];
NSString *timeStr = [dateFormatter stringFromDate: gmtTime];
シミュレーターとデバイスの両方が私に与えます9:55 PM (GMT-05:00)
。
私の理解では、私は取得する必要があります10:55 PM (GMT-05:00)
。私は間違っていますか、それとも間違っていますか?