title: How to set Date and time from UIDatePicker to UITextField in 12 hours format
body: <p>If system date is in 24 hours format. I want to set selected date and time in 12 hours format with AM/PM to textfield as input view. I am trying to convert selected date and time but its giving me 24 hours format. Can anyone please help me. Here is my code for conversion: </p>
  
  <pre><code>    let dateFormatter = DateFormatter()
      dateFormatter.dateFormat = "yyyy-MM-dd HH:mm"
      let dateAsString = dateFormatter.string(from: datePickerView.date)
  
      dateFormatter.dateFormat = "yyyy-MM-dd h:mm a"
      let date = dateFormatter.date(from: dateAsString)
      let DateIn12 = dateFormatter.string(from: date!)
      print("12 hour formatted Date:", DateIn12)
  </code></pre>