Javascript Number pad(n, p)
Number.prototype.pad = function(n, p) { var s = '' + this; p = p || '0';//from w w w.j a v a 2s .c om while (s.length < n) s = p + s; return s; }