Compare two dates [duplicate]
问题 This question already has answers here : How to compare two dates in Objective-C (14 answers) Closed 6 years ago . How can I compare two different dates to find out which is the later date? For example, in date1 I will store one date after downloading some data, and in date2 , I will store the current date. Then I need to check which one is greater/later: something like if(date1>date2) . 回答1: Something like: NSDate* timeNow = [NSDate date]; // If less than 30 seconds, do something if (