I am trying to build a datepicker which has today as a minimum date and 1 Feb 2011 as Maximum date.
I have set the minimum date as followed
[picker setMinimumDate: [NSDate date]];
and this works just fine but the MaximumDate does not seem to be correct.
[picker setMaximumDate: [NSDate dateWithNaturalLanguageString:@"11/02/01"]];
How do I set the maximum date correctly?
Found the answer. Thanks anyway for your help.
[picker setDatePickerMode:UIDatePickerModeDate];
NSDateFormatter* formatter1 = [[NSDateFormatter alloc] init];
[formatter1 setLenient:YES];
[formatter1 setDateStyle:NSDateFormatterShortStyle];
[formatter1 setTimeStyle:NSDateFormatterShortStyle];
NSString* dateString = @"February 1 2011 10:00am";
NSDate* maxDate = [formatter1 dateFromString:dateString];
[picker setMinimumDate: [NSDate date]];
[picker setMaximumDate: maxDate];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With