2021年2月10日星期三

Issue Getting Date from String

I'm trying to convert a date string to a Date object but the date object is nil. I'm getting the date string from my server. I have verified that I'm getting the correct date string value.

The string from the server is '2021-02-19T03:05:16.002322'

Here is my code to convert it.

print(thisUser.adminExpiration!)         let dateFormatter = DateFormatter()  dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"  let adminExpirationDate = dateFormatter.date(from: thisUser.adminExpiration!)  print(adminExpirationDate)  

adminExpirationDate is nil. What am I doing wrong?

https://stackoverflow.com/questions/66147557/issue-getting-date-from-string February 11, 2021 at 09:30AM

没有评论:

发表评论