You have to changes the format for working in both case:
var isoDate = "2018-10-31"
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
print(dateFormatter.date(from: isoDate)!)
isoDate = "2016-04-14T10:44:00+0000"
dateFormatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ssZZZ"
print(dateFormatter.date(from: isoDate)!)
solved Format string to date format swift [closed]