なぜ私の「時間」が 3 になるのか理解できません。私は 9 を期待しています。
NSDate* sourceDate = [NSDate date];
NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
NSTimeZone* destinationTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"CST"];
NSInteger sourceGMTOffset = [sourceTimeZone secondsFromGMTForDate:sourceDate];
NSInteger destinationGMTOffset = [destinationTimeZone secondsFromGMTForDate:sourceDate];
NSTimeInterval interval = destinationGMTOffset - sourceGMTOffset;
NSDate *currentTimeConvertedToHQTime = [[[NSDate alloc] initWithTimeInterval:interval sinceDate:sourceDate] autorelease];
NSLog(@"currentTimeConvertedToHQTime = %@", currentTimeConvertedToHQTime);
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"HH"];
int hour = [[dateFormatter stringFromDate:currentTimeConvertedToHQTime] intValue];
[dateFormatter release];
///ログ
2012-08-20 08:55:13.874 QTGSalesTool[3532:707] currentTimeConvertedToHQTime = 2012-08-20 09:55:10 +0000
2012-08-20 08:55:13.878 QTGSalesTool[3532:707] hour = 3