String.prototype.pad = function(l, s){
return (l -= this.length) > 0
? (s = new Array(Math.ceil(l / s.length) + 1).join(s)).substr(0, s.length) + this + s.substr(0, l - s.length)
: this;
};
var seconds = 121;
document.write( Math.floor(seconds / 60) + ":" + (seconds % 60).toFixed().pad(2, "0") );
return (l -= this.length) > 0
? (s = new Array(Math.ceil(l / s.length) + 1).join(s)).substr(0, s.length) + this + s.substr(0, l - s.length)
: this;
};
var seconds = 121;
document.write( Math.floor(seconds / 60) + ":" + (seconds % 60).toFixed().pad(2, "0") );
No comments:
Post a Comment