
Question:
I want to have a time range on a UIDatePicker, so I can display what times users can book a meeting. Say on May 25th, they can book between 12pm and 8 pm, if they scroll to May 26th they can book between 4pm and 8pm.
So I'm wondering how I can display this in a UIDatePicker? Users can't choose time outside of a preset I have for each day.
Any help is appreciated!
Answer1:I found this one, hope this will help you out..
<a href="https://stackoverflow.com/questions/2441282/can-uidatepickers-minimumdate-and-maximumdate-include-time" rel="nofollow">Can UIDatePicker's minimumDate and maximumDate include time?</a>
Enjoy Coding :)
Answer2:Sorry, but no. UIDatePicker can only set ranges for dates. If you want to restrict the range of the hours, you will have to subclass uidatepicker and create your own custom class. Here's a link: <a href="https://stackoverflow.com/questions/2377167/uidatepicker-hours-interval-nscalendarunit" rel="nofollow">UIDatePicker hours interval (NSCalendarUnit?)</a> Hope this helped!
Answer3:I would suggest using UIPickerView to make your own date picker. Every time a date is selected, you can change what times are available inside pickerView:didSelectRow:inComponent:.
Answer4:What I ended up doing was to add a target to the date picker, and check if the time of the date chosen matched the hours I preset and display an alert view if they didn't match.