Q:

Compare nsdate from server and local nsdate

I have two date in string format :-

Server Timestamp = "2015-09-26T13:37:20.000Z";
Local Timestamp(converted into UTC format) = "2015-09-26T13:57:44.000+0000";

Code to convert local date into UTC format is :-
NSDateFormatter* df_utc = [[NSDateFormatter alloc] init];
            [df_utc setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
            [df_utc setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss. SSSZZZ"];

NSString* ts_utc_string = [df_utc stringFromDate:Localnsdate];

// NEED TO CONVERT LOCAL DATA INTO NSDATE INTO NSSTRING BECOZ SERVER DATA I AM GETTING IS IN STRINGFORMAT

I want to compare both the local and server data and want to detect which date is early. 
But when I try to convert those string into nsdate I am not getting nsdate as nil. 
Please help me. 

A:

You will have to convert both of the date string to NSDate objects and then compare them using:
if ([date1 compare:date2] == NSOrderedDescending) {
    NSLog(@"date1 is later than date2");
} else if ([date1 compare:date2] == NSOrderedAscending) {
    NSLog(@"date1 is earlier than date2");
} else {
    NSLog(@"dates are the same");
}

