In NSDateComponents, how do you know if it's AM or PM?

坚强是说给别人听的谎言 提交于 2019-12-12 10:36:53

问题


When I use NSDateComponents, how do I know I'm setting a time as Am or Pm? Or is it 24-hour format? Here's the code:

NSDate *morningEnd = [NSDate date];
NSDateComponents *components1 = [gregorian components:NSUIntegerMax fromDate:morningEnd];
[components1 setHour:11];
[components1 setMinute:59];

How do I know if I'm setting it as 11:59 AM or 11:59 PM?


回答1:


The hour is defined out of 24 hours. 0 - 11 will be AM, 12 - 23 will be PM.

Edit:

Corrected my range to be 0 - 23 as per the comments below. Thanks guys for correcting me.



来源:https://stackoverflow.com/questions/13042980/in-nsdatecomponents-how-do-you-know-if-its-am-or-pm

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