JavaScript setUTCMinutes()Method

Date 对象参考手册JavaScript Date Object

Examples

Set the minutes field to 17 according to UTC time:

var d = new Date();
d.setUTCMinutes(17);

dOutput according to local time:


Try it Yourself »

Definition and Usage

The setUTCMinutes() method is used to set the minutes of a specified time 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 setUTCMinutes() method


Syntax

Date.setUTCMinutes(min,sec,millisec)

Parameter Values

Parameter Description
min Required. The value of the minutes field to set for the date Object, expressed in UTC.

This parameter should be an integer between 0 and 59:

  • -1 is the last second of the previous minute
  • 60 is the first second of the next minute
sec Optional. The value of the seconds field to set for dateObject. Expressed in UTC.

This parameter is an integer between 0 and 59:

  • -1 is the last second of the previous minute
  • 60 is the first second of the next minute
millisec Optional. The value of the milliseconds field to set for the date Object. Expressed in UTC.

This parameter is an integer between 0 and 999:

  • -1 is the last millisecond of the previous second
  • 1000 is the first millisecond of the next second

Return Value

Type Description
Number The number of milliseconds from midnight January 1, 1970 to the set time.

Technical Details

JavaScript Version: 1.3


More Examples

Example

In this example, we will set the minutes field of the current time to 90 minutes ago via the setUTCMinutes() method:

var d = new Date();
d.setUTCMinutes(d.getUTCMinutes()-90);

dOutput according to current time:


Try it Yourself »


Date 对象参考手册JavaScript Date Object

Other Extensions