The difference between IOS YYYY and YYYY

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.