Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Minimum date to UIDatePicker

I have a date in UILabel(like 'Dec 14, 2010). This date i want to set as minimum date of my UIDatepicker. How can i do this please reply?

Thanks Nishant

like image 365
iphonedev23 Avatar asked Sep 08 '26 23:09

iphonedev23


2 Answers

Convert your UILabel text in to date format using NSDateFormatter and put that value replacing "Date" in following example:

UIDatepicker *datePicker;

NSDate *Date=[NSDate date];

datePicker.minimumDate=Date;
like image 66
Tariq Avatar answered Sep 11 '26 01:09

Tariq


You can use NSDateFormatter and use setDateFormat method for setting Date format.

[formatter setDateFormat:@"MMM dd,yyyy"];

NSDate *date = [formatter dateFromString:lblDate.text];

datePicker.minimumDate=date;
like image 25
Kapil Choubisa Avatar answered Sep 11 '26 01:09

Kapil Choubisa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!