JavaScript Date setUTCDate() Method

Definition and Usage

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

Tip:Coordinated Universal Time (UTC) is the time set by the world time standard.

Note:UTC time is the same as GMT time (Greenwich Mean Time).

Example

Example 1

Set the date of the month according to UTC:

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

Try It Yourself

Example 2

Set the last day of the previous month for the day of the current month:

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

Try It Yourself

Example 3

Set a specific date for the day of the month:

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

Try It Yourself

Syntax

Date.setUTCDate(day)

Parameter Value

Parameter Description
day

Required. An integer representing the day of the month.

Expected value is 1-31, but other values are allowed:

  • 0 will result in the last day of the previous month
  • -1 will result in the day before the last day of the previous month

If a month has 31 days:

  • 32 will result in the first day of the following month

If a month has 30 days:

  • 32 will result in the second day of the following month

Technical Details

Return Value: A numerical value representing the number of milliseconds between the Date object and midnight on January 1, 1970.
JavaScript Version: ECMAScript 1

Browser Support

Method Chrome IE Firefox Safari Opera
setUTCDate() Support Support Support Support Support

Related Pages

Tutorial:JavaScript Date

Tutorial:JavaScript Date Format

Tutorial:JavaScript Date Setting Methods