Javascript Date setUTCMinutes(minutes)

Introduction

Javascript Date setUTCMinutes(minutes) sets the UTC date's minutes.

dateObj.setUTCMinutes(minutesValue[, secondsValue[, msValue]])

Parameters

  • minutesValue An integer between 0 and 59, representing the minutes.
  • secondsValue Optional. An integer between 0 and 59, representing the seconds. If you specify the secondsValue parameter, you must also specify the minutesValue.
  • msValue Optional. A number between 0 and 999, representing the milliseconds. If you specify the msValue parameter, you must also specify the minutesValue and secondsValue.

Return value

The number of milliseconds between 1 January 1970 00:00:00 UTC and the updated date.

If a parameter is outside of the expected range, setUTCMinutes() updates the date accordingly.

For example, if you use 100 for secondsValue, the minutes will be incremented by 1 (minutesValue + 1), and 40 will be used for seconds.

Setting the minutes to a number greater than 59 also increments the hour.

var d = new Date();
console.log(d);/*w  ww  . jav a2s.  c  o m*/
d.setUTCMinutes(43);
console.log(d);

Set the date time to be 90 minutes ago, using UTC methods:

var d = new Date();
d.setUTCMinutes(d.getUTCMinutes() - 90);
console.log(d);/*from   ww  w . j  a  v a  2  s  . c  o m*/



PreviousNext

Related