计算两个date的天数差

//计算两个date的天数差
- (NSInteger)numberFromDayWithFromDay:(NSDate *)fromday{
    NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
    [gregorian setFirstWeekday:2];
    
    NSDate *todate = [NSDate date];
    
    NSDateComponents *daycomponent = [gregorian components:NSCalendarUnitDay fromDate:fromday toDate:todate options:0];
    return daycomponent.day;
}

你可能感兴趣的:(计算两个date的天数差)