[Solved] How to compare two given times with current time? [duplicate]

Comparing 2 NSDates. … NSDate *date1= [formatter dateFromString:time1]; NSDate *date2 = [formatter dateFromString:time2]; if ([date2 compare:date1] == NSOrderedDescending) { NSLog(@”date1 is later than date2″); } else if ([date2 compare:date1] == NSOrderedAscending) { NSLog(@”date1 is earlier than date2″); } else { NSLog(@”dates are the same”); } UPD: via Switch … NSDate *date1= [formatter dateFromString:time1]; NSDate *date2 … Read more