无论如何我可以检查当前时间是否在两个时间之间?
当前时间 = 12:00 AM
时间 A:上午 8:00
时间 B:下午 3:00
这将返回 true,这不会:
当前时间:下午 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
关于iphone - 检查当前时间是否在时间 A 和 B 之间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12238395/