[Solved] How to change JSON string to date format in tableview


In which format do you want to convert. Try this one with your desired format

if let dateString = JSONList[indexPath.row].createdDate{

let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
let date = dateFormatter.date(from: dateString)
dateFormatter.dateFormat = "dd/MM/yyyy"
let dateStr = dateFormatter.string(from:date!)

cell.Date.text = dateStr

}

0

solved How to change JSON string to date format in tableview