ES6 - setUTCMinutes() 方法



JavaScript 的 date setUTCMinutes() 方法根據世界標準時間設定指定日期的分鐘。

語法

Date.setUTCMinutes(minutesValue[, secondsValue[, msValue]])      

引數

  • minutesValue − 一個介於 0 和 59 之間的整數,表示分鐘。

  • secondsValue − 一個介於 0 和 59 之間的整數,表示秒數。如果您指定 secondsValue 引數,則也必須指定 minutesValue。

  • msValue − 一個介於 0 和 999 之間的數字,表示毫秒。如果您指定 msValue 引數,則也必須指定 minutesValue 和 secondsValue。

如果您未指定 secondsValue 和 msValue 引數,則使用 getUTCSeconds 和 getUTCMilliseconds 方法返回的值。

如果您指定的引數超出預期範圍,則 setUTCMinutes 會嘗試相應地更新 Date 物件中的日期資訊。例如,如果您對 secondsValue 使用 100,則分鐘 (minutesValue) 將增加 1 (minutesValue + 1),並且將使用 40 作為秒數。

示例

var dt = new Date( "Aug 28, 2008 23:30:00" ); 
dt.setUTCMinutes(65); 
console.log( dt );        

輸出

Fri Aug 29 2008 00:35:00 GMT+0530 (India Standard Time)        
廣告

© . All rights reserved.