Skip to content

Instantly share code, notes, and snippets.

@killa-kyle
Created February 14, 2015 03:58
Show Gist options
  • Save killa-kyle/b89c911f23332e9663dd to your computer and use it in GitHub Desktop.
Save killa-kyle/b89c911f23332e9663dd to your computer and use it in GitHub Desktop.
timecode conversion
// 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