码迷,mamicode.com
首页 > 其他好文 > 详细

NSDate NSTimerZone 时区转换

时间:2014-06-07 07:46:59      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:c   a   int   string   name   for   

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

NSDate NSTimerZone 时区转换

标签:c   a   int   string   name   for   

原文地址:http://www.cnblogs.com/tangbinblog/p/3770395.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!