title: swift - how to convert date from am/pm to 24 hour format
body: <p>Here is the thing.
  I have my iPhone in am/pm format and iPhone Language in Spanish(MX).
  when I ask for the date, I get something like 2018-03-21 5:14:59 a. m. +0000 and it's a date type, then I try to convert it to string in 24hours format, and I get something like 2018-03-20 23:14:59 and it's a String type, BUT when I try to convert that string into date, I get the same date in am/pm format again 2018-03-21 5:14:59 a. m. +0000
  I don't know what else to do, all I want is convert my am/pm date to 24hours date NOT STRING.
  Help me please.
  Here is my code in Swift 4</p>
  
  <pre><code>    let todayDate = Date()
      print("todayDate: \(todayDate)")
      let dateFormatter = DateFormatter()
      dateFormatter.locale = Locale(identifier: "en_US_POSIX")
      dateFormatter.dateFormat = "yyyy-MM-dd' 'HH:mm:ss"
      let stringDate = dateFormatter.string(from: todayDate)
      print("stringDate: \(stringDate)")
      let dateFromString = dateFormatter.date(from: stringDate)
      print("dateFromString: \(dateFromString!)\n\n\n")
  </code></pre>
  
  <p>this is my console results </p>
  
  <pre><code>    todayDate: 2018-03-21 5:14:59 a. m. +0000
      stringDate: 2018-03-20 23:14:59
      dateFromString: 2018-03-21 5:14:59 a. m. +0000
  </code></pre>