title: How to get a String value from the UIDatePicker
body: <p>I'm trying to allow the user to select a time with a <code>UIDatePicker</code> and when that time comes that matches the timepicker, a code will be implemented. I'm trying to find out how to get a <code>UIDatePicker</code>'s selected time to be a string so I can use it in a separate part of my app. I found a few questions on StackOverFlow in Objective-C on how to convert the <code>UIDatePicker</code>'s  input into a string, but I have not found anything in Swift. Please help.</p>
  
  <pre><code>func setDateAndTime() {
      dateFormatter.dateStyle = DateFormatter.Style.short
      dateFormatter.timeStyle = DateFormatter.Style.short
      dateTimeDisplay.text = dateFormatter.string(from: datePicker.date) + " " + dateFormatter.string(from: datePicker.date)
      datePicker.textInputMode = "\(dtpk.date)"
      datePicker.textInputContextIdentifier = "\(dtpk.date)"
  }
  </code></pre>
  
  <p>I didn't get any errors on this code, but my app always crashed when <code>setDateAndTime()</code> was executed </p>