JavaScript日付setDate

日を設定します。

構文

date.setDate(day)

使用例

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

const
new
setDate
of
the
console
const date = new Date(2024, 0, 15);
date.setDate(1);   // First of the month
console.log(date.getDate());   // 1