Minimum and maximum Date in date Picker in iphone

Posted by Iphony on Stack Overflow See other posts from Stack Overflow or by Iphony
Published on 2012-05-08T07:09:00Z Indexed on 2012/06/04 4:40 UTC
Read the original article Hit count: 163

Filed under:
|
|
|
|

I want to get minimum and maximum date from date picker but minimum date should be "- 18" of current date and 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 formate..

pls suggest any way ...

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c