js日期函数--getMonth
来源:互联网 发布:雷洋 知乎 编辑:程序博客网 时间:2024/05/18 19:38
一、 getMonth 方法返回 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);
}
二、实例,在为某个时间+45天求出过了这么多天后的日期为:
<script type="text/javascript">
var d = new Date();
var date = new Date()
date.setYear(2010);
date.setMonth(10-1);
date.setDate(18);
date.setDate(date.getDate()+45);
alert(date.getFullYear()+"/"+(date.getMonth()+1)+"/"+date.getDate());
</script>
- js日期函数--getMonth
- js中getMonth()+1
- getMonth()函数的问题
- js中的getDate() getMonth() getFullYear()方法;js如何获取当前日期/年月日
- js 中使用getUTCMonth() 与 getMonth() 区别
- js中的getDate() getMonth() getFullYear()方法
- js日期时间函数
- js日期时间函数
- JS日期时间函数
- js日期时间函数
- js日期时间函数
- js日期时间函数
- js 日期函数
- js日期时间函数
- js日期时间函数
- js 日期函数
- js日期格式化函数
- js验证日期函数
- VOA Special English 学习总攻略
- 项目中的pickupwindows原理大揭秘
- 【项目经验】iphone之ASIHTTPRequest
- JavaScript创意游戏:请画一个小人-网址
- Android获取所在地城市名
- js日期函数--getMonth
- 网站站长必读 关于搜索引擎排名的重要性
- RedHat9 下 Linux编译工具Gcc-4.4.3的安装详解
- 正则表达式30分钟入门教程
- MYSQL 存储过程带参数 按时间创建相应的表
- Python特殊语法:filter、map、reduce、lambda、yield
- When the C Run-Time (CRT) library and Microsoft Foundation Class (MFC) libraries are linked in the w
- mini2440登录校园网/802.1x认证
- eclipse 代码索引(Index,代码同步)