Created
February 20, 2014 00:58
-
-
Save ushiboy/9104870 to your computer and use it in GitHub Desktop.
JSON.stringifyでタイムゾーン付けてDate送るとか。
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.toUTCJSON = Date.prototype.toJSON; | |
Date.prototype.toJSON = function() { | |
var sep = this.toString().match(/\w{3}\s\w{3}\s(\d{2})\s(\d{4})\s(\d{2}:\d{2}:\d{2})\sGMT(\+\d{4})/); | |
return sep[2] + '-' + ('0' + this.getMonth()).slice(-2) + '-' + sep[1] + 'T' + sep[3] + sep[4]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment