Created
April 8, 2020 05:59
-
-
Save jeffery812/ef534ac0b7f30f2ff44c4f66ad0afc4a to your computer and use it in GitHub Desktop.
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
// https://stackoverflow.com/questions/33145005/swift-nsdateformatter-not-using-correct-locale-and-format/61094162#61094162 | |
extension Date { | |
var timestamp: String { | |
let dataFormatter = DateFormatter() | |
dataFormatter.locale = Locale(identifier: "en_US_POSIX") | |
dataFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSSS" | |
return String(format: "%@", dataFormatter.string(from: self)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment