iOS时间差8小时问题

方案一:设置正确的时区

//NSCalendar NSDateFormatter
.timeZone = [NSTimeZone timeZoneWithName:@"UTC"];

方案二:添加上差的时间

NSTimeZone* timeZone = [NSTimeZone systemTimeZone];
        NSInteger second = [timeZone secondsFromGMTForDate:startDate];
        startDate = [startDate dateByAddingTimeInterval:second];

你可能感兴趣的:(iOS)