Created
February 14, 2015 03:58
-
-
Save killa-kyle/b89c911f23332e9663dd to your computer and use it in GitHub Desktop.
timecode conversion
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
// convert milliseconds to hours, minutes, seconds | |
var prettyTime = function() { | |
return function(value) { | |
var hours = Math.floor(value / 3600), | |
mins = '0' + Math.floor((value % 3600) / 60), | |
secs = '0' + Math.floor((value % 60)); | |
mins = mins.substr(mins.length - 2); | |
secs = secs.substr(secs.length - 2); | |
if(!isNaN(secs)){ | |
if (hours){ | |
return hours+':'+mins+':'+secs; | |
} else { | |
return mins+':'+secs; | |
}; | |
} else { | |
return '00:00'; | |
}; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment