HomeTechios - Swift: Converting string to date

ios – Swift: Converting string to date

[ad_1]

First of all, this is an excellent resource. I think what you are looking for is this:

func dateStringToDate(dateString: String) -> Date? 
    let dateFormatter = DateFormatter()
    dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS"
    return dateFormatter.date(from: dateString)


dateStringToDate(dateString: "2022-09-09T07:00:00.0000000")

Sep 9, 2022 at 7:00 AM

You have the year, then month, then day, then hour, minute, second, fractional seconds


[ad_2]

Source link

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments

%d bloggers like this: