NSCalendar 类的
- (NSDateComponents *)components:(NSUInteger)unitFlags fromDate:(NSDate *)startingDate toDate:(NSDate *)resultDate options:(NSUInteger)opts
获取startDate与endDate 之间相隔几天
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifi er:NSGregorianCalendar];
NSDate *startDate = ...;
NSDate *endDate = ...;
unsigned int unitFlags = NSDayCalendarUnit;
NSDateComponents *comps = [gregorian components:unitFlags fromDate:startDate toDate:endDate options:0];
int days = [comps day];
- (NSDateComponents *)components:(NSUInteger)unitFlags fromDate:(NSDate *)startingDate toDate:(NSDate *)resultDate options:(NSUInteger)opts
获取startDate与endDate 之间相隔几天
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifi
NSDate *startDate = ...;
NSDate *endDate = ...;
unsigned int unitFlags = NSDayCalendarUnit;
NSDateComponents *comps = [gregorian components:unitFlags fromDate:startDate
int days = [comps day];