- 获取当前日期
-(NSString *)currentDate
{
NSDateFormatter *format = [[NSDateFormatter alloc]init];
NSDate *date = [NSDate date];
[format setDateFormat:@"yyyy-MM-dd"];
return [format stringFromDate:date];
}
- 判断日期是否是今天
-(BOOL)isToday:(NSString *)dateStr
{
NSDateFormatter *format = [[NSDateFormatter alloc]init];
[format setDateFormat:@"yyyy-MM-dd"];
NSDate *date = [format dateFromString:dateStr];
return [[NSCalendar currentCalendar] isDateInToday:date];
}
网友评论