METHOD:
Date::setUTCMinutes
object.setUTCMinutes(minutesVal
[, secondsVal, msVal])
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).
The available parameters are as follows:
minutesVal - an integer (0 thru 59) representing
the minutes.
secondsVal - this value is an integer (0 thru
59) that represents the seconds. If
you supply this parameter you also must supply minutesVal.
msVal - this value is a number between 0 and 999
that represents milliseconds.
If this value is supplied, you must also supply minutesVal
and secondsVal.
The following code 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.
Code:
myDate = new Date()
document.write(myDate +"<br>")
myDate.setUTCMinutes(15, 100)
document.write(myDate)
Output:
Fri Jul 9 13:47:32 UTC+0100 1999
Fri Jul 9 13:16:40 UTC+0100 1999 |