ES6 - setMinutes() 方法

JavaScript date setMinutes() 方法根据本地时间设置指定日期的分钟数。

语法

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

参数

  • minutesValue − 0 到 59 之间的整数,表示分钟数。

  • secondsValue − 0 到 59 之间的整数,表示秒数。如果指定了 secondsValue 参数,还必须指定 minutesValue。

  • msValue − 0 到 999 之间的数字,表示毫秒数。如果指定了 msValue 参数,则还必须指定 minutesValue 和 secondsValue。

如果没有指定 secondsValue 和 msValue 参数,则将使用 getSeconds 和 getMilliseconds 方法返回的值。

示例

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

输出

Thu Aug 28 2008 23:45:00 GMT+0530 (India Standard Time)