Skip to content

Instantly share code, notes, and snippets.

@rcaos
Created May 20, 2021 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcaos/861ad72d107e049f766eaa7b194f7257 to your computer and use it in GitHub Desktop.
Save rcaos/861ad72d107e049f766eaa7b194f7257 to your computer and use it in GitHub Desktop.
DateFormatter swift timezone locale Date
private let dateFormatter: DateFormatter
let locale: Locale = Locale.current
let timezone: TimeZone = TimeZone.current
dateFormatter = DateFormatter()
dateFormatter.locale = locale
dateFormatter.timeZone = timezone
dateFormatter.setLocalizedDateFormatFromTemplate("ddMMyyyy")
let stringDate = dateFormatter.string(from: date)
// Output:
// 20/05/2010 //spanishPeru
// 20/05/2010 //unitedKingdom
// 20.05.2010 //german,
// 2010-05-20 //Canada,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment