I want to get the minimum and maximum date from a date picker, but minimum date should be "- 18" of the current date and the maximum date should be "- 100" of current date.
Suppose current year is 2018 then I want minimum date 2000 and maximum date 1918.
What I have done so far is :
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [gregorian components:NSYearCalendarUnit fromDate:[NSDate date]];
NSInteger year = [components year];
int mindt = year - 18;
int maxdt = year -100;
// NSDate * MinDate = [components year] - 18;
// NSDate * MaxDate = [components year] - 100;
// self.datePicker.minimumDate = MinDate;
// self.datePicker.maximumDate = MaxDate;
but I cant get this integer to my date format..
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…