Created
May 20, 2021 19:08
-
-
Save rcaos/861ad72d107e049f766eaa7b194f7257 to your computer and use it in GitHub Desktop.
DateFormatter swift timezone locale Date
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
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