JavaScript setUTCDate()Method

Date 对象参考手册JavaScript Date Object

Example

Set the day of the month according to universal time (UTC):

var d = new Date();
d.setUTCDate(15);

dOutput:


Try it Yourself »

Definition and Usage

The setUTCDate() method sets the day of the month according to universal time (UTC).

Tip:Coordinated Universal Time, also known as World Unified Time, World Standard Time, International Coordinated Time, abbreviated as UTC (Universal Coordinated Time).

Note:UTC time is GMT (Greenwich) time.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the setUTCDate() method.


Syntax

Date.setUTCDate(day)

Parameter Values

Parameter Description
day Required. The day of the month to set for the dateObject, in universal time.

The parameter is an integer between 1 and 31:

  • 0 is the last hour of the previous month
  • -1 is the hour before the last hour of the previous month

If this month has 31 days:

  • 32 is the first day of the next month

If this month has 30 days:

  • 32 is the second day of the next month

Return Value

Type Description
Number The number of milliseconds between January 1, 1970 and the adjusted date.

Technical Details

JavaScript Version: 1.3


More Examples

Example

Set the date to the last day of the previous month:

var d = new Date();
d.setUTCDate(0);

dOutput:


Try it Yourself »

Example

Set the day of the month:

var d = new Date("July 21, 1983 01:15:00");
d.setUTCDate(15);

dOutput:


Try it Yourself »


Date 对象参考手册JavaScript Date Object

Other Extensions