计算时间差距

-(NSString*)getCurrentTime

{

NSDateFormatter*formatter = [[NSDateFormatteralloc]init];

[formattersetDateFormat:@"yyyy-MM-dd HH:mm:ss"];

NSString*dateTime = [formatterstringFromDate:[NSDatedate]];

startTime=dateTime;

returndateTime;

}




NSDateFormatter*formatter = [[NSDateFormatteralloc]init];

[formattersetDateFormat:@"yyyy-MM-dd HH:mm:ss"];

NSDate*date1 = [formatterdateFromString:startTime];

NSDate*date2 = [NSDatedate];

NSTimeIntervalaTimer = [date2timeIntervalSinceDate:date1];

inthour = (int)(aTimer/3600);

intminute = (int)(aTimer - hour*3600)/60;

intsecond = aTimer - hour*3600- minute*60;

NSString*dural = [NSStringstringWithFormat:@"%d时%d分%d秒", hour, minute,second];

你可能感兴趣的:(计算时间差距)