title: why i get an error in the date formatter code?
body: <p>I’m trying to convert my AM PM time pickers to 24h format to print the start and end time to calculate the price but i got an unknown error. attached is photo of my UI to simplify the idea and my code.
  Note: the end time is automatically shows after i choose the start time
  <img src="https://i.stack.imgur.com/WFHYZ.png" alt="My UI" /></p>
  <pre><code>@objc func donePressed(){
    // formatter
    let formatter = DateFormatter()
    formatter.dateStyle = .none
    formatter.timeStyle = .short
             
    startTimeTxt.text = formatter.string(from: StartTimePicker.date)
    self.view.endEditing(true)
             
    endTimeTxt.text = formatter.string(from: EndTimePicker.date)
    self.view.endEditing(true)
          
    let starttimecal = StartTimeTxt.text!
    let endtimecal = EndTimeTxt.text!
          
    let StartTo24 = starttimecal
    let EndTo24 = endtimecal
    let dateFormatter = DateFormatter()
    dateFormatter.dateFormat = &quot;h:mm a&quot;
  
    let sTime = dateFormatter.date(from: startTo24)
    dateFormatter.dateFormat = &quot;HH:mm&quot;
    let sTime24 = dateFormatter.string(from: sTime!)
    print(&quot;24 hour formatted Date:&quot;, sTime24)
    let eTime = dateFormatter.date(from: endTo24)
    dateFormatter.dateFormat = &quot;HH:mm&quot;
    let eTime24 = dateFormatter.string(from: eTime!) // here the fatal error comes after i choose the start time from simulator 
    print(&quot;24 hour formatted Date:&quot;, eTime24)
  }
  </code></pre>