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;
}
时间: 2024-10-28 03:09:35