JavaScript » Date » setUTCMinutes

object.setUTCMinutes(minutesVal [, secondsVal, msVal])
an integer (0 thru 59) representing the minutes.
this value is an integer (0 thru 59) that represents the seconds. If you supply this parameter you also must supply minutesVal.
this value is a number between 0 and 999 that represents milliseconds. If this value is supplied, you must also supply minutesVal and secondsVal.

This method is used to set the minutes for the supplied date according to universal time.

This method is used to set the minutes field for the supplied date according to universal time. If you do not supply the secondsVal and msVal arguments, JavaScript will use the values returned using the getUTCSeconds and getMilliseconds methods. Also, if the supplied argument is outside the range expected, the setUTCMinutes method will alter the other parameters accordingly (see example below).


myDate = new Date()
document.write(myDate +"<br>")
myDate.setUTCMinutes(15, 100)
Fri Jul 9 13:47:32 UTC+0100 1999
Fri Jul 9 13:16:40 UTC+0100 1999

This example uses the setUTCMinutes method to change the value of the myDate object and also demonstrates how this method will adjust the other parameters if a value is supplied that exceeds the expected range. In this case the secondsVal supplied is 100 which causes the minutesVal value to be incremented by 1.

This is calculated thus:
100 - 60 (maximum expected value for seconds) = 40 (this increments minuteVal by one).

The result of this calculation (40) is then used for the secondsVal parameter.