Created
January 13, 2015 05:41
-
-
Save denniszhao/3faa9ad74383274d004c to your computer and use it in GitHub Desktop.
formatTime
This file contains hidden or 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
/** | |
* Formats number of seconds to hh:mm:ss format. | |
*/ | |
formatTime: function (seconds) { | |
var minutes = Math.floor(seconds / 60), | |
hours = Math.floor(minutes / 60), | |
h = (hours !== 0) ? hours + ":" : "", | |
m = (minutes % 60 !== 0) ? (minutes % 60) + ":" : ((h === "") ? "" : "00:"), | |
s = (seconds % 60 !== 0) ? (seconds % 60) : "00"; | |
return h + m + s; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment