NSDateFormatter提供错误的时间(4分钟差异!!)

时间:2013-01-25 19:54:18

标签: ios objective-c cocoa-touch nsdate nsdateformatter

  

可能重复:
  Setting NSDateComponents results in incorrect NSDate

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

0 个答案:

没有答案