Confused here… I have two dates which I NSLog to console and get:
dates are 2011-03-30 13:33:57 +0000 - 2011-03-28 13:33:57 +0000
One date is clearly later than the other… However, in the code below it doesn’t matter if I use [dateUSERPREFS laterDate:dateXML] or [dateUSERPREFS earlierDate:dateXML] I get “we get first IF” displaying in the console?
Any ideas? Thanks,
NSDate *dateXML = [df dateFromString:last_modifiedXML];
NSDate *dateUSERPREFS = [df dateFromString:last_modifiedUSERPREFS];
NSLog(@"dates are %@ - %@", dateXML, dateUSERPREFS);
if ([dateUSERPREFS laterDate:dateXML]) {
NSLog(@"we get first IF");
}
[aDate laterDate:anotherDate]returns anNSDate, not aBOOL. Specifically, it returns the later of the two dates.You want to use
compare:instead:Alternatively, you could use
[dateUSERPREFS timeIntervalSinceDate:dateXML]which gives you the (signed) number of seconds fromdateXMLtodateUSERPREFS.