//计算当前时间与订单生成时间的时间差,转化成分钟
-(NSInteger)dateTimeDifferenceWithStartTime:(NSString *)startTime
{
NSDate *now = [NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
NSDate *startDate =[formatter dateFromString:startTime];
NSString *nowstr = [formatter stringFromDate:now];
NSDate *nowDate = [formatter dateFromString:nowstr];
NSTimeInterval start = [startDate timeIntervalSince1970]*1;
NSTimeInterval end = [nowDate timeIntervalSince1970]*1;
NSTimeInterval value = end - start;
int second = (int)value %60;//秒
int minute = (int)value /60%60;
int house = (int)value / (24 * 3600)%3600;
int day = (int)value / (24 * 3600);
NSString *str;
NSInteger time;//剩余时间为多少分钟
if (day != 0) {
str = [NSString stringWithFormat:@"耗时%d天%d小时%d分%d秒",day,house,minute,second];
time = day*24*60+house*60+minute;
}else if (day==0 && house != 0) {
str = [NSString stringWithFormat:@"耗时%d小时%d分%d秒",house,minute,second];
time = house*60+minute;
}else if (day== 0 && house== 0 && minute!=0) {
str = [NSString stringWithFormat:@"耗时%d分%d秒",minute,second];
time = minute;
}else{
str = [NSString stringWithFormat:@"耗时%d秒",second];
}
return time;
}