title: Timezone in swift
body: <p>I am struggling quite a bit with dates. I have the following code:</p>
  <p>Current Date in Amsterdam: 22-Februari-2022 - 11:40</p>
  <p>Current Date in New York: 22-Februari-2022 - 05:40</p>
  <p>The dateBoughtString goes in as follows: 2022-02-18T19:50:47.081Z
  The current date is just the current date.</p>
  <pre><code>let dateFormatterNew = DateFormatter()
      dateFormatterNew.dateFormat = &quot;yyyy-MM-dd'T'HH:mm:ss.SSS'Z'&quot;
      dateFormatterNew.timeZone = TimeZone(abbreviation: &quot;GMT+1:00&quot;)
      dateFormatterNew.locale = Locale(identifier: &quot;nl-NL&quot;)
      let dateBoughtTemp = dateFormatterNew.date(from: positionStatsString[0])!
  
      print(dateBoughtTemp) // Prints: 2022-02-18 18:50:47 +0000
      
      dateFormatterNew.timeZone = TimeZone(abbreviation: &quot;GMT-5:00&quot;)
      dateFormatterNew.locale =  Locale(identifier: &quot;en_US&quot;)
      let dateNowTemp = dateFormatterNew.string(from: Date())
      let dateBoughtTempTwo = dateFormatterNew.string(from: dateBoughtTemp)
  
      print(dateNowTemp) // Prints: 2022-02-22T05:41:49.973Z
      print(dateBoughtTempTwo) // Prints: 2022-02-18T13:50:47.081Z
  
      let dateNow = dateFormatterNew.date(from: dateNowTemp)
      let dateBought = dateFormatterNew.date(from: dateBoughtTempTwo)
  
      print(dateNow!)  // Prints: 2022-02-22 10:41:49 +0000 **INCORRECT**
      print(dateBought!) // Prints: 2022-02-18 18:50:47 +0000 **INCORRECT**
  </code></pre>
  <p>When I convert to string all seems fine and it works as it should.
  But when I convert those strings back to a date they just go back to Amsterdam time with the current date even being one hour off.</p>
  <p>What am I missing here?</p>