The setUTCDate() method sets the day of the month, according to the UTC time.
The setUTCDate() method sets the day of the month, according to the UTC time.
UTC time is the same as GMT time.
Date.setUTCDate(day)
Parameter | Require | Description |
---|---|---|
day | Required. | An integer representing the day of a month. |
The expected values are 1-31, but other values are allowed:
A Number, representing the number of milliseconds between the date object and midnight January 1 1970
Set the day of the month, according to UTC:
//display the date after changing the day of the month. var d = new Date(); d.setUTCDate(15);/* w w w . j a v a2 s. c o m*/ console.log(d); //Set the day of the month to be the last day of the previous month: //display the date after changing it to be the last day of the previous month. var d = new Date(); d.setUTCDate(0); console.log(d); //Set the day of the month, to a specified date: //display a specified date after changing the day of the month. var d = new Date("July 21, 2010 01:15:00"); d.setUTCDate(15); console.log(d);