UIDatePicker adding one to year

走远了吗. 提交于 2019-12-02 07:06:06

I don´t know if it would change anything but you could try

[formatter setDateFormat:@"yyyy:MM:dd"];

In NSDateFormatter, "Y" and "y" specify different kinds of year that may start on different days. You want "y".

From the NSDateFormatter documentation:

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!