UIDatePicker adding one to year

前端 未结 2 1293
予麋鹿
予麋鹿 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.

    0 讨论(0)
  • 2021-01-23 18:42

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

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

    0 讨论(0)
提交回复
热议问题