iOS 判断时间是不是今天

释放双眼,带上耳机,听听看~!
NSDateComponents *otherDay = [[NSCalendar currentCalendar] components:NSCalendarUnitEra | NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay fromDate:aDate];
NSDateComponents *today = [[NSCalendar currentCalendar] components:NSCalendarUnitEra | NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay fromDate:[NSDate date]];
if([today day] == [otherDay day] &&
   [today month] == [otherDay month] &&
   [today year] == [otherDay year] &&
   [today era] == [otherDay era]) {
    // 是今天
}

 

人已赞赏
iOS文章

xcode 模拟器报错

2020-2-10 13:33:32

iOS文章

iOS 将tableView滚动到顶部

2020-2-10 14:22:36

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索