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");
}
时间: 2024-11-25 20:47:51