title: how to make 24 hours time format from string in Swift
body: <p>I want to convert a string that was generated by the user to a <code>Date</code> data type. I want the time to be in 24-hour format</p>
  
  <pre><code>let dateFormatter = DateFormatter()
  let timeAsString : String = "22:30"
  dateFormatter.dateFormat = "HH:mm"
  
  let timeFromString = dateFormatter.date(from: timeAsString)
  </code></pre>
  
  <blockquote>
    <p>result : "Jan 1, 2000 at <strong>10:30 PM</strong>"</p>
  </blockquote>
  
  <p>but the result is in 12-hour format. How can I get 22:30 as a Date data type?</p>