setSeconds 方法
利用本地時間設定 Date 物件中的秒數值。
function setSeconds(numSeconds : Number [, numMilli : Number])
引數
numSeconds
必要項。 等於秒數值的數值。numMilli
選擇項。 等於毫秒值的數值。
備註
如果不指定選擇性引數,則所有需要選擇性引數的 set 方法都會使用對應的 get 方法所傳回的數值。 例如,如果 numMilli 引數是沒有指定的選擇性引數,JScript 就會使用 getMilliseconds 方法所傳回的值。
若要利用 Coordinated Universal Time (UTC) 設定秒數值,請使用 setUTCSeconds 方法。
如果引數值大於其範圍或者是負數的話,其他的儲存值都會跟著修改。 例如,儲存的日期如果是 "Jan 5, 1996 00:00:00",這時若呼叫 setSeconds(150),則日期會變成 "Jan 5, 1996 00:02:30"。
setHours 方法可以用來設定小時、分鐘、秒和毫秒。
範例
下列範例說明如何使用 setSeconds 方法。
function SetSecondsDemo(nsec){
var d = new Date();
d.setSeconds(nsec);
var s = d.toLocaleString();
return(s);
}