Created
February 5, 2014 18:08
-
-
Save vespoli/8829755 to your computer and use it in GitHub Desktop.
Date: Format JavaScript date to MM/DD/YYYY
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
Date.prototype.toMMDDYYYY = function (key) { | |
function f(n) { | |
// Format integers to have at least two digits. | |
return n < 10 ? '0' + n : n; | |
} | |
return f(this.getUTCMonth() + 1) + '/' + | |
f(this.getUTCDate()) + '/' + | |
this.getUTCFullYear(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment