set the minimum date at the moment, and the displayed date is now + 2 seconds:
myDatePicker.date = [[ NSDate alloc ] initWithTimeIntervalSinceNow: (NSTimeInterval) 2 ]; myDatePicker.minimumDate = [[ NSDate alloc ] initWithTimeIntervalSinceNow: (NSTimeInterval) 0 ];
Do this when you either start Nib or configure the data for the view controller when reused. You can also do this in viewWillAppear.
Extra points: you can add an IBAction method that subtly encourages the user not to choose a warning date:
- (IBAction)datePickerChanged: (id)sender { if ( [ datePicker.date timeIntervalSinceNow ] < 0 ) datePicker.date = now; }
source share