title: Converting UTC date format to local nsdate
body: <p>I am getting from my server a string date in UTC time zone and I need to convert it to the local time zone.</p>
  
  <p>MY CODE:</p>
  
  <pre><code>let utcTime = "2015-04-01T11:42:00.269Z"    
  let dateFormatter = NSDateFormatter()
  dateFormatter.timeZone = NSTimeZone(name: "UTC")
  dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
  let date = dateFormatter.dateFromString(utcTime)
  println("utc: \(utcTime), date: \(date)")
  </code></pre>
  
  <p>this prints - </p>
  
  <p>utc: 2015-04-01T11:42:00.269Z, date: Optional(2015-04-01 11:42:00 +0000)</p>
  
  <p>if I remove </p>
  
  <pre><code>dateFormatter.timeZone = NSTimeZone(name: "UTC") 
  </code></pre>
  
  <p>it prints </p>
  
  <p>utc: 2015-04-01T11:42:00.269Z, date: Optional(2015-04-01 08:42:00 +0000)</p>
  
  <p>my local time zone is UTC +3 
  and in the first option I get UTC
  in the second option I get UTC -3</p>
  
  <p>I should get</p>
  
  <p>utc: 2015-04-01T11:42:00.269Z, date: Optional(2015-04-01 14:42:00 +0000)</p>
  
  <p>So how do I convert the UTC date format to local time?</p>