Compare two dates to get number of days without calculation.
1 day = 86400 seconds..
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"EE LLL d,yyyy"];
NSString *dateStr = @"Tue Dec 17, 2013";
NSDate *date = [dateFormat dateFromString:dateStr];
if ([[NSDate date] timeIntervalSinceDate:date]>86400) {
NSLog(@"%f", [[NSDate date] timeIntervalSinceDate:date]/86400);
}
Dividing date interval by 86400seconds gives number of days.
0 Comment(s)