JavaScript日付setMonth

月を設定します(0〜11)。

構文

date.setMonth(month)

使用例

下記の値を入力するとサンプルに即時反映されます。

const
new
setMonth
December
indexed
console
getMonth
const date = new Date();
date.setMonth(11);   // December (0-indexed)
console.log(date.getMonth());   // 11