- (NSString *)intervalFromLastDate: (NSString *) dateString1toTheDate:(NSString *) dateString2
{
NSDateFormatter *date=[[NSDateFormatter alloc] init];
[date setDateFormat:@"yyyy-MM-dd"];
NSDate *d1=[date dateFromString:dateString1];
NSTimeInterval late1=[d1 timeIntervalSince1970]*1;
NSDate *d2=[date dateFromString:dateString2];
NSTimeInterval late2=[d2 timeIntervalSince1970]*1;
NSTimeInterval cha=late2-late1;
NSString *timeString=@"";
NSString *house=@"";
NSString *min=@"";
NSString *sen=@"";
sen = [NSString stringWithFormat:@"%d", (int)cha%60];
sen=[NSString stringWithFormat:@"%@", sen];
min = [NSString stringWithFormat:@"%d", (int)cha/60%60];
min=[NSString stringWithFormat:@"%@", min];
house = [NSString stringWithFormat:@"%d", (int)cha/3600];
house=[NSString stringWithFormat:@"%@", house];
timeString=[NSString stringWithFormat:@"差小时:%@-----分:%@------秒:%@",house,min,sen];
return timeString;
}
网友评论