Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript setUTCDate() Method

JavaScript setUTCDate() Method

Date Object Reference JavaScript Date object

Example

Set a certain day of the month according to Universal Time (UTC):

var d = new Date();

d.setUTCDate(15);

d Output result:

Try it »


Definition and Usage

The setUTCDate() method is used to set a certain day of the month according to Universal Time (UTC).

**Note:** Coordinated Universal Time, also known as Universal Time, Universal Standard Time, or International Coordinated Time, abbreviated as UTC (Universal Coordinated Time).

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


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the setUTCDate() method.


Syntax

Date

.setUTCDate(

day

)

Parameter value

Parameters Description
day Required. A certain day of the month to set for dateObject, expressed in universal time.

This 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 the current month has 31 days:

    If the current month has 30 days:

    |

    Return Value

    Type Description
    Number The number of milliseconds from January 1, 1970 to 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);

    d Output result:

    Try it »

    Example

    Set a certain day of the month:

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

    d.setUTCDate(15);

    d Output result:

    Try it »


    Date Object Reference JavaScript Date object