Favorites

JavaScript Date.prototype.setDate() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Date.prototype.setDate()
JavaScript Date Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The setDate() method changes the day of the month of a date. Out-of-range values roll over, which makes it easy to add or subtract days.

Description

The setDate() method sets the day of the month, changing the date object in place. Values outside the month's range roll over: day 32 of January becomes 1 February, and day 0 becomes the last day of the previous month. That makes d.setDate(d.getDate() + 7) a reliable way to add a week, including across month and year boundaries.

It returns the new timestamp, and for an invalid date it returns NaN. Because it changes the date object in place, copy it first with new Date(date) if you need to keep the original. The day is set in local time; setUTCDate() works in UTC.

Adding days by changing the date, rather than adding 24 hours of milliseconds, keeps the time of day correct across daylight saving changes, when some days are 23 or 25 hours long.

Syntax

date.setDate(day)

Parameters

  • dayThe day of the month. Values outside 1 to 31 roll over into neighboring months.

Return Value

The new timestamp of the date, in milliseconds.

Example

const d = new Date(2026, 11, 28);
d.setDate(d.getDate() + 7);
console.log(d.toDateString());
d.setDate(0);
console.log(d.toDateString());

Browser Support

The following information will show you the current browser support for the Date.prototype.setDate() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee