码迷,mamicode.com
首页 > 移动开发 > 详细

【ios】判断日期是今天

时间:2016-05-23 14:46:46      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:

    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");

    }

 

【ios】判断日期是今天

标签:

原文地址:http://www.cnblogs.com/kaysun/p/5519791.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!