Skip to content

Instantly share code, notes, and snippets.

@atika
Created March 10, 2016 09:55
Show Gist options
  • Save atika/84f53267f3b3424e75db to your computer and use it in GitHub Desktop.
Save atika/84f53267f3b3424e75db to your computer and use it in GitHub Desktop.
Convert seconds to days, hours, minutes, seconds in Swift
let seconds = 86400*4 + 3600*2 + 65
print(String((seconds / 86400)) + " days")
print(String((seconds % 86400) / 3600) + " hours")
print(String((seconds % 3600) / 60) + " minutes")
print(String((seconds % 3600) % 60) + " seconds")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment