JavaScript add days to date

Опубликовано: 03 Май 2026
на канале: Samovar tutorials
18,482
124

How to add days to date?
Let’s define a function addDays.
The function has two parameters: date to be modified and number of days to add.
We use the setDate function to set the new date.
And we use the getDate function to get the current date value.
So we just add the number of days to the current date.
Here it is.
We got a date a week ago.