Reputation: 2383
Is there anyway I can check if the current time is in between two times?
Current time = 12:00 AM
Time A: 8:00 AM
Time B: 3:00 PM
This would return true, This would not:
Current time: 1:00 PM
A = 1:00 AM
B = 2:00 AM
Upvotes: 0
Views: 833
Reputation: 9039
You can do it with something along these lines:
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
Upvotes: 3