UIDatePicker adding one to year

前端 未结 2 1330
予麋鹿
予麋鹿 2021-01-23 17:54

I have a very strange and confusing problem. I can\'t find anything about it and it seems like a bug with Apple, but if anyone has a suggestion on how to get around this it woul

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-23 18:24

    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.

提交回复
热议问题