Created
April 5, 2018 07:03
-
-
Save vietstone-ng/aece06109d5834d53c4c14dceccec681 to your computer and use it in GitHub Desktop.
Manage datetime 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
import SwiftDate | |
let response = "2018-04-25T06:00:00" | |
let format = "yyyy-MM-dd'T'HH:mm:ss" | |
let utc = Region.GMT() | |
let timeInUTC = response.date(format: .custom(format), fromRegion: utc) | |
print(timeInUTC) | |
let absoluteTime = timeInUTC?.absoluteDate | |
print(absoluteTime) | |
let timeInVietnam = DateInRegion(absoluteDate: absoluteTime!, in: Region.Local()) | |
print(timeInVietnam.description) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment