计算两个日期之间的天数

//计算两个日期之间的天数

- (NSInteger)calcDaysFromBegin:(NSDate *)beginDate end:(NSDate *)endDate {

    NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];

    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];

    //取两个日期对象的时间间隔:

    NSTimeInterval time= [endDate timeIntervalSinceDate:beginDate];

    int days=((int)time)/ (3600*24);

    return days;

}

 

原文地址:https://www.cnblogs.com/chenzq12/p/6213584.html