- (NSInteger)getDifferenceByDate:(NSString *)date {
//获得当前时间
NSDate*now = [NSDatedate];
//实例化一个NSDateFormatter对象
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//设定时间格式
[dateFormattersetDateFormat:@"yyyy-MM-dd"];
NSDate*oldDate = [dateFormatterdateFromString: date];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
unsignedintunitFlags =NSCalendarUnitDay;
NSDateComponents*comps = [gregoriancomponents:unitFlagsfromDate:oldDate toDate:now options:0];
return[compsday];
}
网友评论