I have CEST dates in yyyy-MM-ddTHH:mm:ssZ format. I want to show them in local format. The following function works fine. It shows the time correctly. But in the end I am forced to show the date in "dd.MM.yyyy HH:mm" format. How can i get Local/native DateFormat from iOS.
func changeTime()
{
myLabel.text = convertTimeZoneToLocal(timeZone: "CEST", date: "2017-09-27T18:25:42Z")
}
func convertTimeZoneToLocal(timeZone:String, date:String) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
dateFormatter.timeZone = TimeZone(abbreviation: timeZone)
let dt = dateFormatter.date(from: date)
dateFormatter.timeZone = TimeZone.current
dateFormatter.dateFormat = "dd.MM.yyyy HH:mm" // I want to change this line.
return dateFormatter.string(from: dt!)
}