Skip to content

Instantly share code, notes, and snippets.

@ushiboy
Created February 20, 2014 00:58
Show Gist options
  • Save ushiboy/9104870 to your computer and use it in GitHub Desktop.
Save ushiboy/9104870 to your computer and use it in GitHub Desktop.
JSON.stringifyでタイムゾーン付けてDate送るとか。
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