计算两个时间差:
NSDateFormatter *date = [[NSDateFormatter alloc]init];
[datesetDateFormat:@"yyyy/MM/dd HH:mm:ss"];
NSDate*startD = [datedateFromString:time1];
NSDate*endD = [datedateFromString:time2];
NSTimeInterval start = [startD timeIntervalSince1970]*1;
NSTimeInterval end = [endD timeIntervalSince1970]*1;
NSTimeIntervalvalue = end - start;
NSString*days = [NSStringstringWithFormat:@"%d",(int)value / (24*3600)];
NSString*hours = [NSStringstringWithFormat:@"%d",(int)(value-days.integerValue*24*3600) / 3600];
NSString*minutes = [NSStringstringWithFormat:@"%d",(int)value /60%60];
NSString*format_time = [NSStringstringWithFormat:@"距离截止:%@天%@时%@分",days,hours,minutes];
网友评论