setMinutes 方法
更新:2007 年 11 月
使用当地时间设置 Date 对象中的分钟值。
function setMinutes(numMinutes : Number [, numSeconds : Number [, numMilli : Number]])
参数
numMinutes
必选。一个等于分钟值的数值。numSeconds
可选项。一个等于秒值的数值。如果使用了 numMilli 参数,那么必须提供此参数。numMilli
可选项。一个等于毫秒值的数值。
备注
如果您没有指定可选参数,那么所有采用可选参数的 set 方法都将使用相应的 get 方法返回的值。例如,如果 numSeconds 参数是可选的,但是没有被指定,则 JScript 将使用 getSeconds 方法的返回值。
若要使用协调通用时间 (UTC) 设置分钟值,请使用 setUTCMinutes 方法。
如果参数值大于其取值范围或者为负,则会相应地修改存储的其他值。例如,如果存储的日期是“Jan 5, 1996 00:00:00”,并调用 setMinutes(90),则日期将变为“Jan 5, 1996 01:30:00”。负数的处理方法与此相似。
示例
下面的示例阐释了 setMinutes 方法的用法。
function SetMinutesDemo(nmin, nsec){
var d, s; //Declare variables.
d = new Date(); //Create Date object.
d.setMinutes(nmin, nsec); //Set minutes.
s = "Current setting is " + d.toLocaleString()
return(s); //Return new setting.
}