Created
April 11, 2011 09:12
-
-
Save nefarioustim/913270 to your computer and use it in GitHub Desktop.
Prototype a method onto the Date object that returns a UTCDateTime string.
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.getUTCDateTime = function() { | |
var zf = function(num) { | |
return ((num + 100) + '').substr(1); | |
}; | |
return [ | |
this.getUTCFullYear(), | |
'-', | |
zf(this.getUTCMonth() + 1), | |
'-', | |
zf(this.getUTCDate()), | |
'T', | |
zf(this.getUTCHours()), | |
':', | |
zf(this.getUTCMinutes()), | |
':', | |
zf(this.getUTCSeconds()), | |
'Z' | |
].join(''); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment