javascript 中如何将gmt时间字符串转换成日期

从struts2中取到的json数据为
"Tue Dec 15 00:00:00 GMT+08:00 2009"
是一个格林威治时间字符串
怎样将它转换成date
谢谢!

我也跑了下
firefox,chrome,opera 正常

safari和ie6 有问题

ie7 以上没有测试 :wink:

传值之前先格式话一下,格式化成字符串,不格式化的话,默认就是专成这种格式的。
[code="java"]
Calendar now = Calendar.getInstance();
SimpleDateFormat f = new SimpleDateFormat("yyyy/MM/dd");
String nowTime = f.format(now.getTime());
[/code]

var _date = new Date('Tue Dec 15 00:00:00 GMT+08:00 2009');

[code="java"]var _date = new Date('Tue Dec 15 00:00:00 GMT+0800 2009');[/code]

得把08:00 改成 0800

var date = new Date('Tue Dec 15 00:00:00 GMT+08:00 2009');
alert(date.getFullYear());
alert(date.getMonth());

var date = new Date('Tue Dec 15 00:00:00 GMT+08:00 2009');
在IE6下,是取不到date对象的;firefox下08:00和0800都可以.

var str = 'Tue Dec 15 00:00:00 GMT+08:00 2009';
str = str.slice(0,str.length-8)+str.slice(str.length-7);
var date = new Date(str);
alert(date.getFullYear());
alert(date.getMonth());

java中不想改,可以把这个字符串的倒数第一个冒号replace掉

测试过的 ie火狐 opera 都正常