Node.js examples for Number:Format
Pad a number with leading 0
Number.prototype.pad = function(size) { var s = String(this); if (typeof(size) !== "number") { size = 2;/*w ww .j a v a2 s.co m*/ } while (s.length < size) { s = "0" + s; } return s; }