Date formatting in iOS 9 not working [duplicate]

浪子不回头ぞ 提交于 2019-12-01 20:00:31

Try setting locale on your date formatter.

[dateFormat setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];

From Apple Documentation:

If you're working with fixed-format dates, you should first set the locale of the date formatter to something appropriate for your fixed format. In most cases the best locale to choose is en_US_POSIX, a locale that's specifically designed to yield US English results regardless of both user and system preferences.

EDIT: Swift Version

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