English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript setUTCDate() method

 JavaScript Date Object

setUTCDate()According to the world time setting, set the day of the month in the Date object (1 ~ 31)。

World Standard Time (UTC) is the standard time set for world time.

Expected value is1-31, but other values are allowed:

  • 0 represents the last day of the previous month

  • -1represents the day before the last day of the previous month

If a month has31day:

  • 32is the first day of the next month

If a month has30 days:

  • 32is the second day of the next month

Syntax:

date.setUTCDate(day)
var d = new Date();
d.setUTCDate(12);
Test and see‹/›

Browser Compatibility

All browsers fully support the setUTCDate() method:

Method
setUTCDate()isisisisis

Parameter Value

ParameterDescription
day1to31An integer between the two dates, representing a day in the month

Technical Details

Return Value:1970 Year1Month1Milliseconds between the date 00:00:00 UTC and the update date
JavaScript Version:ECMAScript 1

More Examples

This example sets the last day of the month to the last day of the previous month:

var d = new Date();
d.setUTCDate(0);
Test and see‹/›

 JavaScript Date Object