Javascript Reference - JavaScript setUTCDate() Method








setUTCDate(date)
Sets the day of the month for the UTC date. If the date is greater than the number of days in the month, the month value also gets increased.

UTC time is the same as GMT time.

Browser Support

setUTCDate() Yes Yes Yes Yes Yes

Syntax

dateObject.setUTCDate(day);




Parameter Values

Parameter Description
day Required. An integer representing the day of a month.

Expected values are 1-31, but other values are allowed:
0 will be the last hour of the previous month
-1 will be the hour before the last hour of the previous month

If the month has 31 days, 32 will be the first day of the next month.

Return Value

return a number representing the number of milliseconds between the date value and midnight January 1 1970.

Example


var myDate = new Date();
      
myDate.setUTCDate(23);
console.log(myDate.toString());

The code above generates the following result.