You are creating a string from a date from a time interval from a date, three of the conversions are waste.
The conversion failed because time.description
doesn't match the format yyyy-MM-dd HH:mm:ss+z
To get an ISO8601 string with time zone the date format is yyyy-MM-dd'T'HH:mm:ssZ
and you have to specify a fixed locale
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
let isoString = formatter.string(from: Date())
There is a shorter way as suggested by Rob in the comments
let formatter = ISO8601DateFormatter()
formatter.timeZone = .current
let isoString = formatter.string(from: Date())
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…