0
 let estDf = DateFormatter()
 let gmtDf = DateFormatter()

 gmtDf.timeZone = TimeZone(identifier: "UTC")
 gmtDf.dateFormat = "yyyy-MM-dd','HH:mm:ss"
 let time_ = "2017-10-21,10:53:23"
 let utcDate = gmtDf.date(from: time_)!
 print("UTC :",utcDate)

 let timeZone = TimeZone.autoupdatingCurrent.identifier as String

 estDf.timeZone =  TimeZone(identifier: timeZone)
 estDf.dateFormat = "yyyy-MM-dd','HH:mm:ss"
 let estDate = estDf.date(from: gmtDf.string(from: utcDate))!

 print("Local time",estDate)

While convert from UTC time format to local time format, time is showing one hour after.

So if the UTC time is

  2017-10-21 10:53:23 +0000

local time time showing as

 2017-10-21 10:53:23 +0000

But the actual time in the device is :

 2017-10-21 9:53:23 +0000
jscs
  • 63,694
  • 13
  • 151
  • 195
Joe
  • 859
  • 2
  • 10
  • 27

0 Answers0