NSDate NSTimerZone 时区转换

时间:2014-06-07 07:46:59   收藏:0   阅读:183

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;

}

NSDate NSTimerZone 时区转换,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!