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;

}

posted @ 2014-06-05 15:18  hhhker  阅读(513)  评论(0编辑  收藏  举报