Last active
August 29, 2015 14:00
-
-
Save 64lines/11024200 to your computer and use it in GitHub Desktop.
[JAVASCRIPT] - Convert Seconds to Time Object
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
function secondsToTime(secs) | |
{ | |
var hours = Math.floor(secs / (60 * 60)); | |
var divisor_for_minutes = secs % (60 * 60); | |
var minutes = Math.floor(divisor_for_minutes / 60); | |
var divisor_for_seconds = divisor_for_minutes % 60; | |
var seconds = Math.ceil(divisor_for_seconds); | |
var obj = { | |
"hours": hours, | |
"minutes": minutes, | |
"seconds": seconds | |
}; | |
return obj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment