Skip to content

Instantly share code, notes, and snippets.

@amit-y
Last active August 2, 2016 19:27
Show Gist options
  • Save amit-y/fe1cf307f953ea96531f574a270cb19a to your computer and use it in GitHub Desktop.
Save amit-y/fe1cf307f953ea96531f574a270cb19a to your computer and use it in GitHub Desktop.
ISO 8601 formatted date/time
Date.prototype.toISO8601 = function () {
var dateString = this.toString().split(" ");
return this.toJSON().substring(0,11)+dateString[4]+dateString[5].substr(3,3)+':'+dateString[5].slice(-2);
}
// example usage
(new Date).toISO8601();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment