我已经试了很多方法,但是获得的日期都不是当期日期。这是现在的代码:
NSDateFormatter *tempFormatter = [[NSDateFormatter alloc]init];
[tempFormatter setDateFormat:@"dd-MM-yyy"];
NSDate *currentDate = [NSDate date];
NSDate *fromDate = [NSString stringWithFormat:@"%@",[tempFormatter stringFromDate:currentDate]];
NSLog(@"currentDate %@", fromDate);
NSDate *toDate = [NSString stringWithFormat:@"%@",[tempFormatter stringFromDate:datePicker.date]];
NSLog(@"toDate %@", toDate);
NSTimeInterval interval = [toDate timeIntervalSinceDate:fromDate];
double leftDays = interval/86400;
NSLog(@"Total interval Between::%g",leftDays);
不知道错误在哪儿了,谢谢帮忙。