Skip to content

Instantly share code, notes, and snippets.

@vespoli
Created February 5, 2014 18:08
Show Gist options
  • Save vespoli/8829755 to your computer and use it in GitHub Desktop.
Save vespoli/8829755 to your computer and use it in GitHub Desktop.
Date: Format JavaScript date to MM/DD/YYYY
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