Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Small bit of Swift which displays each dateFormat and timeFormat output when used in a Swift Playground.
let date = Date()
let dateFormatter = DateFormatter()
/*
Date
*/
// Full Date
dateFormatter.dateStyle = .full
dateFormatter.timeStyle = .none
dateFormatter.string(from: date)
// Long Date
dateFormatter.dateStyle = .long
dateFormatter.timeStyle = .none
dateFormatter.string(from: date)
// Medium Date
dateFormatter.dateStyle = .medium
dateFormatter.timeStyle = .none
dateFormatter.string(from: date)
// Short Date
dateFormatter.dateStyle = .short
dateFormatter.timeStyle = .none
dateFormatter.string(from: date)
/*
Time
*/
// Full Time
dateFormatter.dateStyle = .none
dateFormatter.timeStyle = .full
dateFormatter.string(from: date)
// Long Time
dateFormatter.dateStyle = .none
dateFormatter.timeStyle = .long
dateFormatter.string(from: date)
// Medium Time
dateFormatter.dateStyle = .none
dateFormatter.timeStyle = .medium
dateFormatter.string(from: date)
// Short Time
dateFormatter.dateStyle = .long
dateFormatter.timeStyle = .short
dateFormatter.string(from: date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment