Formatting Dates
Display dates with the modern formatting API.
Formatting Dates
Raw Date values are not human-readable. Swift's modern FormatStyle API turns them into localized strings cleanly.
The formatted() Method
Calling .formatted() on a date gives a sensible default string for the user's locale.
import Foundation
let now = Date()
let text = now.formatted()
print("Produced a string: \(!text.isEmpty)")