NSDate returns wrong year

孤街醉人 提交于 2019-12-10 09:07:26

问题


In MyappAppDelegate.m file at "application: didFinishLaunchingWithOptions:" method, I just wrote:

NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy"];
NSDate *date = [NSDate date];
NSLog(@"%@", [df stringFromDate:date]);
return;

And ran with iPhoneSimulator, console said:

2010-10-15 20:38:43.571 Myapp[59828:207] 0022

I can't understand what's happening.

So I created new Xcode project and tested like above, then it correctly returned '2010'. Did I do some bad settings in Myapp?

Thanks in advance.

  • iOS SDK 4.1
  • Xcode 3.2.4
  • using libraries: http://github.com/klazuka/Kal, ttp://www.tbxml.co.uk/TBXML/TBXML_Free.html

回答1:


You are using the japanese calendar.
Check Settings/General/International/Calendar. Set it back to gregorian.



来源:https://stackoverflow.com/questions/3942005/nsdate-returns-wrong-year

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!