NSDate NSTimerZone 时区转换

timeZoneAbbreviation = @“America/New_York”;

#pragma mark - 转换时区

- (NSDate *) convertDate:(NSDate *) date toTimeZone:(NSString *) timeZoneAbbreviation {

    if (!date) {

        return nil;

    }

    NSTimeZone *locationZone  = [NSTimeZonesystemTimeZone];

    NSTimeZone *zoneUTC     =   [NSTimeZone timeZoneWithName:timeZoneAbbreviation];

    NSTimeInterval s        = [zoneUTC secondsFromGMTForDate:date];

    NSTimeInterval p        = [locationZone secondsFromGMTForDate:date];

    NSTimeInterval i = s-p;

    NSDate *d = [NSDatedateWithTimeInterval:i sinceDate:date];

    return d;

}

原文地址:https://www.cnblogs.com/DamonTang/p/3770395.html