其实很简单:
NSDate *now = [NSDate date];
NSDateComponents *oneMonth = [[[NSDateComponents alloc] init] autorelease];
[oneMonth setMonth:1];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *oneMonthFromNow = [calendar dateByAddingComponents:oneMonth toDate:now options:0];
NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
[df setTimeZone:[NSTimeZone timeZoneWithName:@"America/New_York"]];
[df setDateStyle:NSDateFormatterMediumStyle];
[df setTimeStyle:NSDateFormatterMediumStyle];
NSLog(@"Now in New York: %@", [df stringFromDate:now]);
NSLog(@"One month from now in New York: %@", [df stringFromDate:oneMonthFromNow]);
编辑:也就是说,你的问题措辞有点混乱。使用NSDate,您不会在特定时区进行计算。你也得不到“现在的东部时间”。你只要得到
当前时间点
(不考虑时区)并对其进行计算。到特定时区的实际转换仅在输出时发生(当您向用户显示时间时,通常在用户的时区中)。