Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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", ?? 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