Created
June 18, 2021 19:27
-
-
Save ole/9a1de9a7c79555c0d96f24803f3b1df6 to your computer and use it in GitHub Desktop.
ISO8601 date formatting in Foundation in iOS 15/macOS 12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let date = Date.now | |
date.formatted(.iso8601) // "20210618T191800Z" | |
date.formatted(.iso8601.year().month().day().dateSeparator(.dash)) // "2021-06-18" | |
date.formatted(.iso8601.dateSeparator(.dash).timeSeparator(.colon)) // "2021-06-18T19:18:00Z" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment