YouTip LogoYouTip

Jsref Setdate

# JavaScript setDate() Method [![Image 8: Date Object Reference](#) JavaScript Date Object](#) ## Example Set a day of the month: var d = new Date(); d.setDate(15); The output of _d_: Mon Jun 15 2026 01:18:28 GMT+0000 (Coordinated Universal Time) [Try it Yourself Β»](#) * * * ## Definition and Usage The setDate() method is used to set the day of the month. * * * ## Browser Support ![Image 9: Internet Explorer](#)![Image 10: Firefox](#)![Image 11: Opera](#)![Image 12: Google Chrome](#)![Image 13: Safari](#) The setDate() method is supported by all major browsers. * * * ## Syntax _Date_.setDate(_day_) ## Parameter Values | Parameter | Description | | :--- | :--- | | _day_ | Required. A number representing the day of the month (1 - 31): * 0 will result in the last day of the previous month. * -1 will result in the day before the last day of the previous month. If the current month has 31 days: * 32 will result in the first day of the next month. If the current month has 30 days: * 32 will result in the second day of the next month. | ## Return Value | Type | Description | | --- | --- | | Number | The number of milliseconds between January 1, 1970, midnight, and the adjusted date. Before ECMAScript standardization, this method returned nothing. | ## Technical Details | JavaScript Version: | 1.0 | | --- | * * * ## More Examples ## Example Set a day of the month to the last day of the previous month: var d = new Date(); d.setDate(0); The output of _d_: Sun May 31 2026 01:18:28 GMT+0000 (Coordinated Universal Time) [Try it Yourself Β»](#) ## Example In this example, we will set the day of the current month to 15 using the setDate() method: var d = new Date("July 21, 1983 01:15:00"); d.setDate(15); The output of _d_: Fri Jul 15 1983 01:15:00 GMT+0000 (Coordinated Universal Time) [Try it Yourself Β»](#) * * JavaScript Date Object](#)
← Met Table CreatecaptionCss3 Pr Border Image Width β†’