let st = "20170713 111326" let dateFmt = DateFormatter() dateFmt.dateFormat = "yyyyMMdd HHmmss" if let date = dateFmt.date(from: st) { dateFmt.dateFormat = "dd/MM/yyyy HH:mm a" let finalDate = dateFmt.string(from: date)) }