您的浏览器过于古老 & 陈旧。为了更好的访问体验, 请 升级你的浏览器
Ready 发布于2014年08月08日 04:29

原创 JavaScript Date.getMinutes() 函数详解

3043 次浏览 读完需要≈ 3 分钟

内容目录

getMinutes()函数用于使用当地时间返回当前Date对象中的分钟值。也就是"年月日 时分秒"中"风"的数值。

例如:2013年7月15日 13:22:45,就返回22。

该函数属于Date对象,所有主流浏览器均支持该函数

语法

date.getMinutes( )

返回值

getMinutes()函数的返回值为Number类型,返回当前Date对象的分钟值。该值介于 [0, 59] 之间。

示例&说明

// 定义一个当前时间的Date对象(2014-08-07 16:27:39)
var date = new Date();
document.writeln( date.getMinutes() ); // 27

// 定义一个"2001-06-30 12:11:59 230"的Date对象
var date2 = new Date(2001, 5, 30, 12, 11, 59, 230);
document.writeln( date2.getMinutes() ); // 11

// 定义一个"2008-08-08"的Date对象
var date3 = new Date(2008, 7, 8);
document.writeln( date3.getMinutes() ); // 0

运行代码

  • CodePlayer技术交流群1
  • CodePlayer技术交流群2

0 条评论

撰写评论

打开导航菜单