使用协调通用时间 (UTC) 设置 Date 对象中的秒钟值。
function setUTCSeconds(numSeconds : Number [, numMilli : Number ])
- numSeconds
必选。一个等于秒值的数值。
- numMilli
可选项。一个等于毫秒值的数值。
如果您没有指定可选参数,那么所有采用可选参数的 set 方法都将使用相应的 get 方法返回的值。例如,如果 numMilli 参数是可选的,但是没有被指定,则 JScript 将使用 getUTCMilliseconds 方法的返回值。
若要使用当地时间设置秒值,请使用 setSeconds 方法。
如果参数值大于其取值范围或者为负,则会相应地修改存储的其他值。例如,如果所存储的日期是“Jan 5, 1996 00:00:00”,并调用了 setSeconds(150) 方法,那么日期将变为“Jan 5, 1996 00:02:30.00”
示例下面的示例阐释了 setSeconds 方法的用法。
function SetUTCSecondsDemo(nsec, nmsec){ var d, s; //Declare variables. d = new Date(); //Create Date object. d.setUTCSeconds(nsec, nmsec); //Set UTC seconds and milliseconds. s = "Current UTC milliseconds setting is "; s += d.getUTCMilliseconds(); //Get new setting. return(s); //Return new setting. }要求
应用于:
参考
getSeconds 方法getUTCSeconds 方法
setSeconds 方法