好像是从ios4.1開始[NSDate date];获取的是GMT时间,这个时间和北京时间相差8个小时。下面代码能够解决问题
- (void)tDate
{
NSDate *date = [NSDatedate];
NSTimeZone *zone = [NSTimeZonesystemTimeZone];
NSInteger interval = [zone secondsFromGMTForDate: date];
NSDate *localeDate = [date dateByAddingTimeInterval: interval];
NSLog(@"%@", localeDate);
}