Answers for "getting full day name from datetime string in swift"

1

swift get day from available string

let dateString = "2018-12-24 18:00:00 UTC"
    let formatter = DateFormatter()
    formatter.dateFormat = "yyyy-MM-dd HH:mm:ss 'UTC'"
    guard let date = formatter.date(from: dateString) else {
        return
    }

    formatter.dateFormat = "yyyy"
    let year = formatter.string(from: date)
    formatter.dateFormat = "MM"
    let month = formatter.string(from: date)
    formatter.dateFormat = "dd"
    let day = formatter.string(from: date)
    print(year, month, day) // 2018 12 24
Posted by: Guest on February-16-2021

Code answers related to "getting full day name from datetime string in swift"

Code answers related to "Swift"

Browse Popular Code Answers by Language