view raw
YichenBman YichenBman - 10 months ago 54
Swift Question

UIDatePicker 15 Minute Increments Swift


, I'm wondering how I would use my
to select 15 minute increments. So instead of having hours with 60 minutes, I only want to be able to select 00 minutes, 15 minutes, 30 minutes, and 45 minutes.

Here is my current implementation

var schedulePicker: UIDatePicker = UIDatePicker()

schedulePicker.datePickerMode = UIDatePickerMode.DateAndTime
schedulePicker.addTarget(self, action: "handleSchedulePicker:", forControlEvents: UIControlEvents.ValueChanged)
textField9.inputView = schedulePicker

func handleSchedulePicker(sender: UIDatePicker) {
var dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MMM/dd/yy hh:mm a"
textField9.text = "\(dateFormatter.stringFromDate("


Set shedulePicker.minuteInterval = 15

I found the answer here:

It's always good to take a look at documentation :)