In objective C, UIDatePicker is the best way to display date and time options. We can set date of our choice in a Date picker. Also we can set minimum and maximum date.
Here I am creating UIDatePicker first.
- UIDatePicker *pickerDate=[[UIDatePicker alloc]initWithFrame:pickerFrame];
- pickerDate.datePickerMode=UIDatePickerModeDateAndTime;
We can set limits also. Here is the code:-
- //Here I am setting 1 Hour interval to the current date.
- NSDate *date = [NSDate dateWithTimeInterval:3600.0 sinceDate:[NSDate date]];
- [pickerDate setMaximumDate:date];
- [pickerDate setMinimumDate:pickerDate.date];
Here is the code to add time in seconds to set the interval.