SOLVED:使用 Date.parseExact 或这个版本 http://datejs.googlecode.com/svn/trunk/build/date-en-US.js根据这个
使用 date.js 的演示 http://jsfiddle.net/mplungjan/x2APB/
使用 date-en-US.js 的演示 http://jsfiddle.net/mplungjan/X6dYe/
使用我得到的第一个版本
null
http://datejs.googlecode.com/files/date.js
Line 13
当我把断言从测试套件 http://www.datejs.com/test/date_and_time/index.html:
// null
console.log('Date.parse("1985-04-12T23:20:50Z")',
Date.parse('1985-04-12T23:20:50Z'));
// my previous answer works
console.log('Date.parse("1985-04-12T23:20:50Z".replace(...))',
Date.parse('1985-04-12T23:20:50Z'
.replace(/\-/g,'\/')
.replace(/[T|Z]/g,' ')
)
);
// the test suite without the Z works
console.log('1985-04-12T23:20:50',
new Date(1985,3,12,23,20,50).equals( Date.parse('1985-04-12T23:20:50')));
// but this one fails when not in the test suite
try {
console.log('1985-04-12T23:20:50Z',
new Date(1985,3,12,23,20,50).equals( Date.parse('1985-04-12T23:20:50Z')));
}
catch(e) {
console.log('1985-04-12T23:20:50Z',e.message);
}
这是一个较旧的答案 https://stackoverflow.com/questions/3566125/problem-with-date-formats-in-javascript-with-different-browsers不使用 date.js 时出现此问题