いかのコードで2018/2/1と出る想定なのですが、何故か11月となります。。
なぜでしょうか。。。
##JS
JS
1 var dt = new Date(); 2 var today = dt.getFullYear()+"/"+dt.getMonth()+1+"/"+dt.getDate(); 3 4 console.log(dt); 5 console.log(today); 6 console.log(dt.getFullYear()); 7 console.log(dt.getMonth()+1); 8 console.log(dt.getDate());
##console.log結果
Thu Feb 01 2018 13:56:21 GMT+0900 (JST) 2018/11/1 2018 2 1 31
dt.getMonth()が1で、それに+1で11ではないですか?
console.log結果の 31 ってなんですか?
回答3件
あなたの回答
tips
プレビュー