问题
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