Suppose today's date is 16 May 2016, I want to restrict the user to display date up-to 16 jun 2016.
Swift 3
let datePicker = UIDatePicker()
datePicker.maximumDate = Date()
swift 2
let datePicker = UIDatePicker()
datePicker.maximumDate = NSDate()
Restrict user to particular time interval
Try This: It will restrict user to select date greater than one month from current date.
let datePicker = UIDatePicker()
let secondsInMonth: NSTimeInterval = 30 * 24 * 60 * 60
datePicker.maximumDate = NSDate(timeInterval: secondsInMonth, sinceDate: NSDate())
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