title: How to format a date using timezone in Swift?
body: <p>I have checked other questions but none of them helped me much.</p>
  
  <p>I have following string:</p>
  
  <pre><code>let dateString = "2018-04-29T21:00:00.000Z"
  </code></pre>
  
  <p>I have successfully converted it to date using the following:</p>
  
  <pre><code>let dateFormatter = DateFormatter()
  dateFormatter.locale = Locale(identifier: "en_US_POSIX")
  dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
  let convertedDate = dateFormatter.date(from: dateString)
  </code></pre>
  
  <p>But now I only want the time <strong>"hh:mm a"</strong> using <strong>timezone</strong> such as <strong>"+8"</strong>. I have tried following way but it's not working:</p>
  
  <pre><code>let dateFormatter = DateFormatter()
  dateFormatter.timeZone = TimeZone(abbreviation: "UTC+8")
  dateFormatter.dateFormat = "hh:mm a"
  let requiredTime = dateFormatter.string(from: convertedDate!)
  </code></pre>
  
  <p>Can anyone help me to overcome this problem?</p>