title: Understanding dateFormatter in Swift 4
body: <p>I'm having trouble understanding date formatter in Swift. I'm parsing my date from server in this format <code>2018-02-05T14:44:01Z</code> and because of that I set DateFormatter like this <code>dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"</code>. </p>
  
  <p>After that, I'm converting it to Date like this <code>dateFormatter.date(from: stringDateFromServer)</code>. And that's ok, it works (on a device with 24h time format) and I understand why. </p>
  
  <p>But if I run this on device with 12h time format <code>dateFormatter.date(from: stringDateFromServer)</code> it returns <code>nil</code>. I have to add <code>dateFormatter.locale = Locale(identifier: "en_US_POSIX")</code> for it to work on both 12/24h formats. </p>
  
  <p>So my question is: Why should I add .locale if I already set my date format with <code>HH</code>. Shouldn't dateFormatter automatically convert it to users local settings? Also when I add <code>Locale(identifier: "en_US_POSIX")</code> I lose PM/AM in formated string from date [<code>HH:MM</code> (yes I know HH is for 24h)]</p>