Difference between NSDateFormatter 'yyyy' and 'yyyy', nsdateformatter
I saw this when I posted my microblog today:
Immediately, I thought of the bug that BK's feedback came back today. It was okay to run well for more than half a year. Today, I suddenly got a black screen. After debugging, I found that NSDateFormatter was in December 2015, today is July 22, 2014! Therefore, a problem occurs during the create preform operation.
After Google, it was discovered thatYYYYCaused by, change backYyyyThat's all. Specific differences:
After a simple test, I not only authenticated the question above, but also found another problem:
Let's take a look at the test:
It is correct to use [NSDate date] to obtain the current date: 00:42:25 CST (see the debug box on the left ), however, the output is a 16-hour difference between 16:42:25 and 0000 (look at the debug box on the right). It seems to be the time in the United States. After formatting the current time with @ "YYYY-MM-dd", the time difference is, which is one year different, this authentication indeed verifies that @ "YYYY-MM-dd" is calculated on a weekly basis.
For example, on October 28, 2014, there will be one year after the conversion, for example, 28,29, 30,31. On August 29, 2015, there will be one year after Sunday 27; sunday 2016 is the first day of June 2017, that is to say, the last day of weekly conversion calculation is the first day of the next year, so there will be no conversion errors; on Sunday 31, 2017, another year of change occurred .... Then we can see the clues. Let's think about it by yourself,Note: Remember to use the format @ "yyyy-MM-dd" to convert the date format in the future to avoid bugs derived from this situation.
Reference link:
Http://stackoverflow.com/questions/15133549/difference-between-yyyy-and-yyyy-in-nsdateformatter
Http://realmacsoftware.com/blog/working-with-date-and-time