ios时间差

时间:2024-08-06 23:36:56

/**

* @method

*

* @brief 获取两个日期之间的天数

* @param fromDate       起始日期

* @param toDate         终止日期

* @return    总天数

*/

+ (NSInteger)numberOfDaysWithFromDate:(NSDate *)fromDate toDate:(NSDate *)toDate{

NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];

NSDateComponents    * comp = [calendar components:NSCalendarUnitDay

fromDate:fromDate

toDate:toDate

options:NSCalendarWrapComponents];

return comp.day;

}