NSDateFormatter
给了我几乎正确的结果。差异只有4分钟。哪里......它来自哪里??! (时区转换是18000秒=正好是5小时!)
(iOS 6)
NSDate* n = ...;
NSDateFormatter *gmtFormatter = [[NSDateFormatter alloc] init];
[gmtFormatter setDateStyle:NSDateFormatterNoStyle];
[gmtFormatter setTimeStyle:NSDateFormatterShortStyle];
DLog(@"n = %@, formatted to = %@, timeZone = %@", n, [gmtFormatter stringFromDate:n], gmtFormatter.timeZone);
[gmtFormatter release];
结果:
2013-01-25 14:49:29.224 Dictionary [1321:907] n = 0001-01-01 18:57:02 +0000,格式化为= 2:01 PM,timeZone = America / New_York(EST)offset -18000