Chrome中的toLocaleDateString()返回错误的日期

时间:2015-09-29 20:00:21

标签: javascript google-chrome

在google-chrome上运行代码45.0.2454.99 m:



var date = new Date(1500,10,11)

date.setHours(12) // Important to avoid changing the day after localization

document.write(date + "<br>");
document.write(date.toString() + "<br>");
document.write(date.toDateString() + "<br>");
document.write(date.toLocaleDateString() + "<br>");
&#13;
&#13;
&#13;

它返回:

Sun Nov 11 1500 12:00:00 GMT-0200 // 11/11/1500
Sun Nov 11 1500 12:00:00 GMT-0200 // 11/11/1500
Sun Nov 11 1500 // 11/11/1500
01/11/1500 // -- This one differs from the others above

任何人都可以解释我为什么以及如何解决这个问题?

1 个答案:

答案 0 :(得分:1)