setDate() Date instance method setterS2C Home
« Globals « Date « setDate()
Description
Sets the locale specific day of the month (1-31) for the specified date.
Syntax
| Signature | Description |
|---|---|
aDate.setDate(dayInt) | Sets the locale specific day of the month (1-31) for the specified date. |
Parameters
| Parameter | Description |
|---|---|
dayInt | An integer in the range 1-31.
|
Examples
The code below shows examples of the setDate() method of Date.
// Create a Date instance for the current date and time.
var todaysDate = new Date();
alert(todaysDate);
// Set Day of the month.
todaysDate.setDate(-6);
alert(todaysDate + ' - Day set to -6');
todaysDate.setDate(0);
alert(todaysDate + ' - Day set to 0');
todaysDate.setDate(35);
alert(todaysDate + ' - Day set to 35');
Related Tutorials
JavaScript Intermediate Tutorials - Lesson 2 - Dates and Times