Skip to content

Instantly share code, notes, and snippets.

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