the January 31, 2017 conversion became January 31, 2018, a difference of one year. What is this for?
Reason:YYYY is calculated on a weekly basis, we usually calculate the date with the best yyyy,yyyy is the year of the label
if January 1 is Monday, Tuesday, Wednesday, Thursday, it is in 01 weeks. If January 1 is Friday, Saturday or Sunday, it is 52 weeks or 53 weeks in the previous year
Example:
Use yyyy time
NSDate *currentdatetime =*fomatter = [[nsdateformatteralloc]init];[ Fomatter Setdateformat:@ "yyyy-mm-dd hh:mm"*curentdatestr = [ Fomatterstringfromdate:currentdatetime];
Use yyyy time
NSDate *currentdatetime =*fomatter = [[nsdateformatteralloc]init];[ Fomatter Setdateformat:@ "yyyy-mm-dd hh:mm"*curentdatestr = [ Fomatterstringfromdate:currentdatetime];
Conclusion: These two codes are no different for most of the time, but if the current time is for example: 2015-12-29 Such a date then the first code taken out of the date is 2015-12-29 the second part became 2016-12-29 difference one year
Although it is a small problem, but encountered do not know, the elimination of the problem is very disgusting. I hope you will remember later.
By:lm
The difference between IOS YYYY and YYYY