Node.js examples for Number:Format
Pad a number
Number.prototype.pad = function(size) { var s = String(this); if (typeof(size) !== "number") { size = 2;//from w w w . ja va 2 s . com } while (s.length < size) { s = "0" + s; } return s; };