Yesterday was the weekend, but the company suddenly told me the online version, unable to request data. I tried it, and it was! The token overtime! of the pop-up window report This is odd, guess is the time is wrong, printed the event, found unexpectedly is December 27, 2016. I don't believe it, how can this good time be wrong, and then
1 NSDate *date = [[NSDate alloc]init]; 2 NSLog (@ "%@", date);
The output is right, December 27, 2015. That's NSDateFormatter's fault, and he tried it again.
1NSDate *date =[[NSDate alloc]init];2NSLog (@"%@", date);3NSDateFormatter *formatter =[[NSDateFormatter alloc] init];4[Formatter Setdateformat:@"YYYYMMDD"];5NSString *datestr =[Formatter stringfromdate:date];6NSLog (@"%@", DATESTR);
Oh da!! The result is December 27, 2016, I am really drunk, this can be wrong. Google on the search, and really someone has encountered, the original is the event format [formatter Setdateformat:@ "YYYYMMdd"]; with YYYY, And the Big Y represents the weekly count of December 27 is exactly the last weekend of 2015, and according to the United States, the weekend is the first day of the week, so press @ "YYYYMMdd"Formatter after it became 16 years.
Change the event grid to [formatter Setdateformat:@ "yyyyMMdd"];
everything OK;.
Everywhere is the pit, or should pay attention to code specification, careful!
Event errors in yyyy and YYYY in NSDateFormatter--climbing pits