You can probably use a simple C-style code and get the difference as an integer, and then decide what you need to return from the comparison function, depending on whether the difference is positive or negative. You can also compare minutes this way. Remember to import time.h.
time_t now = time(NULL);
struct tm oldCTime;
localtime_r(&now, &oldCTime);
int hours = oldCTime.tm_hour;
int diff = 17-hours;
NSLog(@"Time difference is: %d.", diff);
source
share