【ios】判断日期是今天
NSDate *currentDate = [NSDate date]; NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *components = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:currentDate]; NSDate *today = [calendar dateFromComponents:components]; components = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:self.birthday]; NSDate *otherDate = [calendar dateFromComponents:components]; if([today isEqualToDate:otherDate]) {
NSLog(@"today");
}