Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare two dates [duplicate]

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).

like image 221
Kiran Avatar asked Apr 20 '11 08:04

Kiran


1 Answers

Something like:

    NSDate* timeNow = [NSDate date];

    // If less than 30 seconds, do something
    if ([timeNow timeIntervalSinceDate:anEarlierTime] < 30.0f)
    {
        // Do something
    }
like image 126
Dave F Avatar answered Oct 24 '22 08:10

Dave F