Skip to content

Instantly share code, notes, and snippets.

@adeubank
Created August 19, 2013 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adeubank/6271703 to your computer and use it in GitHub Desktop.
Save adeubank/6271703 to your computer and use it in GitHub Desktop.
Add a method to print the United States date format to the global Date object for JavaScript.
// Add toUSDateString to global Date object, prints Mon/Day/Year
Date.prototype.toUSDateString = function () {
return (this.getMonth() + 1) + "/" + this.getDate() + "/" + this.getFullYear();
};
(new Date()).toUSDateString(); // "MM/DD/YYYY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment