使用encodeURIComponent
> encoded = encodeURIComponent('Fri, 11 May 2014 01:23:45 +0000')
< "Fri%2C%2011%20May%202014%2001%3A23%3A45%20%2B0000"
> decodeURIComponent(encoded)
< "Fri, 11 May 2014 01:23:45 +0000"
see
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponentsee
http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1see
http://en.wikipedia.org/wiki/Percent-encoding#The_application.2Fx-www-form-urlencoded_typeBase64
> encoded = btoa('Fri, 11 May 2014 01:23:45 +0000')
< "RnJpLCAxMSBNYXkgMjAxNCAwMToyMzo0NSArMDAwMA=="
> atob(encoded)
< "Fri, 11 May 2014 01:23:45 +0000"
对于这种格式(GMT)的时间建议用Date预处理成ISO 8601
> new Date('Fri, 11 May 2014 01:23:45 +0000').toISOString()
< "2014-05-11T01:23:45.000Z"
ISO 8601格式相对问题少些