在NSDateComponents中,您如何知道它是上午还是下午? [英] In NSDateComponents, how do you know if it's AM or PM?
本文介绍了在NSDateComponents中,您如何知道它是上午还是下午?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用NSDateComponents时,如何知道将时间设置为Am或Pm?还是24小时制?这是代码:
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];
我怎么知道将其设置为上午11:59还是下午11:59?
How do I know if I'm setting it as 11:59 AM or 11:59 PM?
推荐答案
小时定义为24小时. 0-11将是上午,12-23将是下午.
The hour is defined out of 24 hours. 0 - 11 will be AM, 12 - 23 will be PM.
根据以下评论将我的范围更正为0-23.谢谢你们纠正我.
Corrected my range to be 0 - 23 as per the comments below. Thanks guys for correcting me.
这篇关于在NSDateComponents中,您如何知道它是上午还是下午?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文