【发布时间】:2011-07-31 22:10:13
【问题描述】:
我从 CLLocation 经理那里收到了一个时间戳,我想将其更正为英国夏令时 (GMT+1)。我可以使用 dateFormatter 执行此操作并获取 NSString ...
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setLocale:[NSLocale currentLocale]];
[dateFormatter setTimeStyle:NSDateFormatterLongStyle];
NSString *dateString = [dateFormatter stringFromDate:dateNow];
NSLog(@"DATE: %@", dateString);
我的问题是,有没有办法获取 NSDate,将其本地化为 GMT+1,结果是一个新的 NSDate。我想我可以使用上面的方法并添加 dateFromString: 但这感觉就像是一种非常冗长的方式来做我需要的事情。基本上有没有办法去 NSDate > NSDate 而不必跳过中间的 NSString?
【问题讨论】:
标签: iphone objective-c cocoa-touch