Skip to content

Instantly share code, notes, and snippets.

@hamaluik
Created November 15, 2013 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamaluik/7477314 to your computer and use it in GitHub Desktop.
Save hamaluik/7477314 to your computer and use it in GitHub Desktop.
This isn't something that is very difficult. However, I often find I need to do the conversion from total number of seconds (example: 5412s) to the number of hours, minutes, and seconds that is (hh:mm:ss - 1:30:12 in this case). Here is a little snippet in Python that does this.
# secs is the total number of seconds
secs = 5412
# calculate things..
hours = secs / 3600
minutes = (secs - hours * 3600) / 60
seconds = secs % 60
# now print the results!
print '%02d:%02d:%02d' % (hours, minutes, seconds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment