Last active
June 10, 2021 16:35
-
-
Save alekseylichtman/d983c2ad63726e418c69688ea3a9d693 to your computer and use it in GitHub Desktop.
Swift. Get Date() with timezone
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
extension Date { | |
var currentUTCTimeZoneDate: String { | |
let calendar = Calendar.current | |
let timeZone = calendar.timeZone.identifier | |
let formatter = DateFormatter() | |
formatter.timeZone = TimeZone(identifier: timeZone) | |
formatter.amSymbol = "AM" | |
formatter.pmSymbol = "PM" | |
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ" | |
print(formatter) | |
return formatter.string(from: self) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment