title: How to convert UTC string to local date in swift?
body: <p>I have following UTC like <code>2020-07-15T12:32:38+00:00</code>. I actually need to convert this string to local date in phone taking into account a timezone. Here is my try that I see from other <a href="https://stackoverflow.com/a/42811162/6455473">stackoverflow</a> answers:</p>
  <pre><code>func UTCToLocal(date: String) -&gt; Date? {
      let dateFormatter = DateFormatter()
      dateFormatter.dateFormat = &quot;yyyy-MM-dd'T'HH:mm:ssZ&quot;
      //I thought than below can help 
      dateFormatter.timeZone = TimeZone(abbreviation: &quot;UTC&quot;)
      return dateFormatter.date(from: date)
  }
  </code></pre>
  <p>Another approach:</p>
  <pre><code>func UTCToLocal2(date: String) -&gt; Date? {
     let dateFormatter = DateFormatter()
     dateFormatter.dateFormat = &quot;yyyy-MM-dd'T'HH:mm:ssZ&quot;
     /// I thought that specifying current time zone would help 
     dateFormatter.timeZone = TimeZone.current
     return dateFormatter.date(from: date)
  }
  </code></pre>
  <p>But none of approach works. My <code>2020-07-15T12:32:38+00:00</code> is not converted to date with my timezone. Where is my mistake?</p>