Skip to content

Instantly share code, notes, and snippets.

@ala747
Created March 9, 2013 09:53
Show Gist options
  • Save ala747/5123682 to your computer and use it in GitHub Desktop.
Save ala747/5123682 to your computer and use it in GitHub Desktop.
function format(ms) {
//console.log(t[5])
var d = new Date(ms + t[5]).toString()
.replace(/.*([0-9][0-9]:[0-9][0-9]:[0-9][0-9]).*/, '$1');
var x = ms % 1000;
d += '.' + addZeros(Math.round(x), 3);
return d;
}
function addZeros(number, digits, place) {
var number = String(number),
digits = digits ? digits : 3;
if (!place || place == 'pre') {
while (number.length < digits) number = '0' + number;
} else {
while (number.length < digits) number = number + '0';
}
return number;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment