一个日期 Fri, 11 May 2014 01:23:45 +0000 经 url 传递(get),然后,
就变成了 Fri, 11 May 2014 01:23:45   0000 注意 + 号没有了
这个好像是 w3c 的标准。。。大家是怎么解决的?
|  |      1free9fw      2015-05-08 11:04:22 +08:00 urlencode | 
|  |      2liuhaotian      2015-05-08 11:08:14 +08:00 +是空格被encode之后的结果,这时候你需要进行 urlencode 获取后进行 urldecode | 
|  |      3jasonding      2015-05-08 11:20:03 +08:00 加号和空格的互转问题,你可以encode/decode三次来破解这个黑魔法。不过如果没有特殊原因的话,replace就够了 | 
|  |      4whatisnew OP @liuhaotian 那上 + 号是字符串,不是 encode 之后的 | 
|  |      5lianyue      2015-05-08 11:23:24 +08:00 %20 变成 | 
|  |      6Septembers      2015-05-08 11:27:16 +08:00 使用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/encodeURIComponent see http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1 see http://en.wikipedia.org/wiki/Percent-encoding#The_application.2Fx-www-form-urlencoded_type Base64 > 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格式相对问题少些 | 
|  |      7cpp255      2015-05-08 11:31:42 +08:00 HttpServer decode会把 + 转为空格,把"+" replace 为 “%2B” | 
|      8MaiCong      2015-05-08 11:32:43 +08:00 http://www.w3school.com.cn/jsref/jsref_encodeURIComponent.asp http://www.w3school.com.cn/jsref/jsref_decodeURIComponent.asp var time = encodeURIComponent('Fri, 11 May 2014 01:23:45 +0000'); console.log(time + '\n' + decodeURIComponent(a)); | 
|  |      9liuhaotian      2015-05-08 11:36:27 +08:00 @whatisnew 我的意思是,这个+是空格encode的结果。因此已经被识别为空格了。 | 
|  |      10Septembers      2015-05-08 11:39:11 +08:00 @liuhaotian 我引用的规范里有说 | 
|  |      11msg7086      2015-05-08 11:54:45 +08:00 过url传递前必须先encode。 | 
|      12CodeDrift      2015-05-08 13:22:07 +08:00 | 
|      13neilwong      2015-05-08 16:31:31 +08:00 我奇怪的是get传递参数为什么不是timestamp而是这么一串字符串~ |