Created
November 15, 2013 00:54
-
-
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.
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
# 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