setUTCDate()
Date
instance method
JS Home <<
JS Reference <<
Date <<
setUTCDate()
Description
Sets the UTC day of the month (1-31) for the specified date.
Syntax
Signature | Description |
---|---|
aDate.setUTCDate(dayInt) | Sets the UTC 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 setUTCDate()
method of Date
.
// Create a Date instance for the current date and time.
var todaysDate = new Date();
alert(todaysDate);
// Set UTC Day of the month.
todaysDate.setUTCDate(-6);
alert(todaysDate + ' - UTC Day set to -6');
todaysDate.setUTCDate(0);
alert(todaysDate + ' - UTC Day set to 0');
todaysDate.setUTCDate(35);
alert(todaysDate + ' - UTC Day set to 35');
Related Tutorials
JavaScript Intermediate Tutorials - Lesson 2 - Dates and Times