NSDate *senddate = [NSDate date];
NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init];
[dateformatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
// 截止时间字符串格式
NSString *expireDateStr = self.orderDetailModel.create_time;
// 当前时间字符串格式
NSString *nowDateStr = [dateformatter stringFromDate:senddate];
// 截止时间data格式
NSDate *expireDate = [dateformatter dateFromString:expireDateStr];
// 当前时间data格式
NSDate * nowDate = [dateformatter dateFromString:nowDateStr];
// 当前日历
NSLog(@"%@",nowDateStr);
NSCalendar *calendar = [NSCalendar currentCalendar];
// 需要对比的时间数据
NSCalendarUnit unit = NSCalendarUnitYear | NSCalendarUnitMonth
| NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
// 对比时间差
NSDateComponents *dateCom = [calendar components:unit fromDate:expireDate toDate:nowDate options:0];
dateCom的.minute和hour 可以获得差距