-(NSString*)getTimeWithDays:(NSInteger)add dis:(NSInteger)dis{ NSInteger days = 0; if (add!=0) { days=add; } if (dis!=0) { days=-dis; } NSDateFormatter *formatter=[[NSDateFormatter alloc]init]; [formatter setDateFormat:@"yyyy-MM-dd"]; NSDate*nowDate=[NSDate date]; NSTimeInterval oneDay = 24*60*60*1; NSDate *theDate=[nowDate initWithTimeIntervalSinceNow:+oneDay*days]; NSString *dataTime=[formatter stringFromDate:theDate]; NSLog(@"%@",dataTime); return dataTime;}
直接调用。。。就好了