Last active
August 2, 2016 19:27
-
-
Save amit-y/fe1cf307f953ea96531f574a270cb19a to your computer and use it in GitHub Desktop.
ISO 8601 formatted date/time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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