Skip to content

Instantly share code, notes, and snippets.

@Kelderic
Created January 24, 2019 13:01
Show Gist options
  • Save Kelderic/5042ca25e8080eea26c0704e6b3644ca to your computer and use it in GitHub Desktop.
Save Kelderic/5042ca25e8080eea26c0704e6b3644ca to your computer and use it in GitHub Desktop.
Javascript has Date.toLocaleDateString and Date.toLocaleTimeString, but no toISODateString. This code adds in the missing functionality.
Date.prototype.toISODateString = function() {
// CREATE ISO STRING AND RETURN JUST THE DATE PORTION
return this.toISOString().split('T')[0];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment