JavaScriptDatesetDate

Sets the day of the month for a specified date.

Syntax

date.setDate(day)

Example

Enter values below to update the example in real time.

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