Difference between 'YYYY' and 'yyyy' in NSDateFormatter Difference between 'YYYY' and 'yyyy' in NSDateFormatter ios ios

Difference between 'YYYY' and 'yyyy' in NSDateFormatter


Also when using a date format string using the correct format is important.

@"YYYY" is week-based calendar year.

@"yyyy" is ordinary calendar year.

You can go through the whole blog, its a good to give it a look

enter image description here

https://web.archive.org/web/20150423093107/http://realmacsoftware.com/blog/working-with-date-and-time

http://realmacsoftware.com/blog/working-with-date-and-time (dead link)


A common mistake is to use YYYY. yyyy specifies the calendar year whereas YYYY specifies the year (of “Week of Year”), used in the ISO year-week calendar. In most cases, yyyy and YYYY yield the same number, however they may be different. Typically you should use the calendar year.

from Apple Docs


dd/MMM/YYYY - e.g.:1 01/Jan/2000; answer : 19/dec/1999              (see weekly calendar December month last Monday              suppose leaf year + 1 day)dd/MMM/yyyy - eg: ordinary - no problem.