當我從字符串構造一個日期對象時,我得到了令人困惑的結果。如果我沒有指定時間,似乎時間是任意選擇的(但可重複)。Javascript日期構造函數使用任意時間
var d1=new Date("2013-10-9"), d2=new Date("2013-10-10");
output = d1+' '+d1.toUTCString()+'<br>\n';
output += d2+' '+d2.toUTCString()+'<br>\n';
鉻20.0 ...
Wed Oct 09 2013 00:00:00 GMT-0600 (MDT) Wed, 09 Oct 2013 06:00:00 GMT
Wed Oct 09 2013 18:00:00 GMT-0600 (MDT) Thu, 10 Oct 2013 00:00:00 GMT
爲什麼會選擇鉻不同的時間10月10日?
順便說,解決辦法是在這裏:https://stackoverflow.com/a/744134/86967
Dup'ed發現:http://stackoverflow.com/q/43060107/86967 – nobar