SOLUTION
— The setDate() function changes the day of the month in a date object.
const date = new Date();
date.setDate(10);
— To specify a particular day for a date:
const customDate = new Date("February 14, 2022");
customDate.setDate(28);
— Use setMonth() to modify the month of a date (January is 0, February is 1, and so on).
Set the month to 7 (August):
const today = new Date();
today.setMonth(7);
— Change both the month and the day to create a specific date:
const newDate = new Date();
newDate.setMonth(3, 15);
— Call setFullYear() to update the year in a date object. This function can also adjust the month and day.
const currentYear = new Date();
currentYear.setFullYear(2024);
const specialDate = new Date();
specialDate.setFullYear(2024, 6, 30);