IOS获取两个日期之间的时间间隔

    NSString *formeDateString = @"2016-01-1";
    NSDate *nowDate = [NSDate date];
    NSDateFormatter *dateFormate = [[NSDateFormatter alloc]init];
    [dateFormate setDateFormat:@"yyyy-MM-dd"];
    NSDate *formeDate = [dateFormate dateFromString:formeDateString];
    
    NSCalendar *dateCalendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
    NSDateComponents *components = [dateCalendar components:NSCalendarUnitDay fromDate:formeDate toDate:nowDate options:NSCalendarWrapComponents];
    

 

posted @ 2016-01-21 15:43  击水湘江  阅读(1254)  评论(0编辑  收藏  举报