Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
无论如何我可以检查当前时间是否在两次之间?
当前时间 = 上午 12:00 时间 A:上午 8:00 时间 B:下午 3:00
这将返回真,这不会: 当前时间:下午 1:00 A = 上午 1:00 B = 凌晨 2:00
您可以按照以下方式进行操作:
NSDate *timeA, *timeB; // Whatever and however you want to set these; NSDate *now = [NSDate date]; If([now compare:timeA] == NSOrderedDescending && [now compare:timeB] == NSOrderedAscending) // then now is between timeA and Time B