Setting NSDate in a “TimePicker” with 24 - 12 hours format xcode

假装没事ソ 提交于 2019-12-01 01:55:55
Kevin Horgan

Take a look at this like: Find if user prefers 12 / 24 Hour Clock?… think the second answer might be the best for you. Then depending on if the user's device uses a 12 hour clock or 24 hour clock you can set your [currentDate setDateFormat:....] accordingly.

If you want a 12 hour clock then set currentDate as follows:

[currentDate setDateFormat:@"yyyy-MM-dd h:mm:ss a"];

If you want a 24 hour clock then set currentDate as follows:

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