目录

setMinutes()

描述 (Description)

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

语法 (Syntax)

下面给出了setMinutes()方法的语法。

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

参数细节 (Parameter Detail)

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

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

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

例子 (Example)

以下示例演示了CoffeeScript中setMinutes()方法的用法。 将此代码保存在名为date_setminutes.coffee的文件中。

dt = new Date "February 19, 2016 23:15:00"
dt.setMinutes 45
console.log dt

打开command prompt并编译.coffee文件,如下所示。

c:\> coffee -c date_setminutes.coffee

在编译时,它为您提供以下JavaScript。

// Generated by CoffeeScript 1.10.0
(function() {
  var dt;
  dt = new Date("February 19, 2016 23:15:00");
  dt.setMinutes(45);
  console.log(dt);
}).call(this);

现在,再次打开command prompt ,然后运行CoffeeScript文件,如下所示。

c:\> coffee date_setminutes.coffee

执行时,CoffeeScript文件生成以下输出。

Fri Feb 19 2016 23:45:00 GMT+0530 (India Standard Time)
↑回到顶部↑
WIKI教程 @2018