首页 > 学院 > 开发设计 > 正文

getMonth 方法

2019-11-17 06:02:23
字体:
来源:转载
供稿:网友

 

返回 Date 对象中用本地时间表示的月份值。

dateObj.getMonth()

必选项 dateObj 参数为 Date 对象。

说明

要获取用全球标准时间 (UTC)表示的月份值,请使用 getUTCMonth 方法。

getMonth 方法返回一个处于 0 到 11 之间的整数,它代表 Date 对象中的月份值。这个整数并不等于按照惯例来表示月份的数字,而是要比按惯例表示的值小 1。假如一个 Date 对象中保存的时间值是 "Jan 5, 1996 08:47:00",那么 getMonth 方法就会返回 0。

示例

下面这个例子说明了 getMonth 方法的用法:

function DateDemo(){   var d, s = "今天日期是: ";   d = new Date();   s += (d.getMonth() + 1) + "/";   s += d.getDate() + "/";   s += d.getYear();   return(s);}


上一篇:getMinutes 方法

下一篇:getSeconds 方法

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表