iOS计算两个时间的时间差

+ (long)calculteHourL:(NSDate *)endDate startDate:(NSDate *)startDate {

NSCalendar *cal = [NSCalendar currentCalendar];

unsigned int unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;

NSDateComponents *d = [cal components:unitFlags fromDate:endDate toDate:startDate options:0];

long hour = [d hour] + [d minute]/60 + [d second]/3600;

return hour;

//    int sec = [d hour]*3600 + [d minute]*60 + [d second];

//    NSLog(@"second = %d",[d hour]*3600+[d minute]*60+[d second]);

}

上一篇:关于quartusII 错误 Error: Current license file does not support the EP*** device 错误原因总结


下一篇:poj 3253 Fence Repair(priority_queue)