Easy Tutorial
❮ Prop Win Screenx Prop Video Currentsrc ❯

JavaScript setDate() Method

JavaScript Date Object

Example

Setting a specific day of the month:

d Output result:


Definition and Usage

The setDate() method is used to set the day of the month.


Browser Support

All major browsers support the setDate() method.


Syntax

Parameter Values

Parameter Description
day Required. A number representing the day of the month (1 ~ 31): 0 is the last day of the previous month<br> -1 is the day before the last day of the previous month If the current month has 31 days: 32 is the first day of the next month If the current month has 30 days: 32 is the second day of the next month

Return Value

Type Description
Number The number of milliseconds from midnight of January 1, 1970, to the adjusted date. Prior to ECMAScript standardization, this method returned nothing.

Technical Details

| JavaScript Version: | 1.0 | | --- | --- |


More Examples

Example

Setting the day of the month to the last day of the previous month:

d Output result:

Example

In this example, we will set the day of the current month to 15 using the setDate() method:

d Output result:


JavaScript Date Object

❮ Prop Win Screenx Prop Video Currentsrc ❯