Created
June 5, 2019 21:03
-
-
Save nanotroy/dadf94fb967c5fdb3510bbe673fc679c 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
func countDownString(from date: Date, until nowDate: Date) -> String { | |
let calendar = Calendar(identifier: .gregorian) | |
let components = calendar | |
.dateComponents([.day, .hour, .minute, .second] | |
,from: nowDate, | |
to: date) | |
return String(format: "%02dd:%02dh:%02d:%02ds", | |
components.day ?? 00, | |
components.hour ?? 00, | |
components.minute ?? 00, | |
components.second ?? 00) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment