Skip to content

Instantly share code, notes, and snippets.

@popcornomnom
Created June 11, 2019 20:06
Show Gist options
  • Save popcornomnom/92157ccbe33552d0769c2fb60253dc14 to your computer and use it in GitHub Desktop.
Save popcornomnom/92157ccbe33552d0769c2fb60253dc14 to your computer and use it in GitHub Desktop.
func timeString(from timeInterval: TimeInterval) -> String {
let seconds = Int(timeInterval.truncatingRemainder(dividingBy: 60))
let minutes = Int(timeInterval.truncatingRemainder(dividingBy: 60 * 60) / 60)
let hours = Int(timeInterval / 3600)
return String(format: "%.2d:%.2d:%.2d", hours, minutes, seconds
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment