NSDateFormatter dateFromString and iPhone in 24 Hour Format Confusion

前端 未结 5 1631
小蘑菇
小蘑菇 2020-12-03 05:04

I\'m having a problem. I get incoming time strings in 12-hour format, and I\'m turning them into NSDate objects. When the iPhone is in 12 hour format, no problem. But when i

5条回答
  •  独厮守ぢ
    2020-12-03 05:17

    Not sure if you still need it, but I've had a similar problem which got solved by setting the locale for the date formatter. That is, if you want to force it to 12-hour mode, regardless of the user's 24/12 hour mode setting, you should set the locale to en_US_POSIX.

提交回复
热议问题