Last active
March 17, 2017 01:09
-
-
Save marclave/67c588cbe107c0987e7810288c59e52f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number.prototype.pad = function(size) { | |
var s = String(this); | |
while (s.length < (size || 2)) {s = "0" + s;} | |
return s; | |
} | |
(9).pad(); //returns "09" | |
// OR | |
var d = new Date(); | |
var padded = ('0' + d.getHours()).slice(-2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment