//计算还款日与当前时间的差
- (int)intervalSinceNow: (NSString *) theDate {
// NSDateFormatter *formatter=[[NSDateFormatter alloc] init];
// [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
// NSDate *date = [formatter dateFromString:theDate];
//
// NSString *string = [formatter stringFromDate:[NSDate date]];
// NSLog(@"->>> %@", string);
//
// NSTimeInterval late = [date timeIntervalSince1970]*1;
//
// NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0];
// NSTimeInterval now = [dat timeIntervalSince1970]*1;
// NSString *timeString = @"";
//
// NSTimeInterval cha = now - late;
//
// if (cha/86400 > 1) {
// timeString = [NSString stringWithFormat:@"%f", cha/86400];
// timeString = [timeString substringToIndex:timeString.length-7];
// return [timeString intValue];
// }
// return -1;
NSDateFormatter *date=[[NSDateFormatter alloc] init];
[date setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *d=[date dateFromString:theDate];
NSTimeInterval late=[d timeIntervalSince1970]*1;
NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0];
NSTimeInterval now=[dat timeIntervalSince1970]*1;
NSString *timeString=@"";
NSTimeInterval cha=now-late;
if (cha/86400>1)
{
timeString = [NSString stringWithFormat:@"%f", cha/86400];
timeString = [timeString substringToIndex:timeString.length-7];
return [timeString intValue];
}
return -1;
}