javascript getDate getMonth返回错误的月份 [英] javascript getDate getMonth returns wrong month

查看:313
本文介绍了javascript getDate getMonth返回错误的月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有关于此的其他帖子,但我无法弄清楚我在这里做错了什么。以下是我的代码:

I know there have been other posts about this but I can't see to figure out what I am doing wrong here. Below is my code:

var d = new Date();
var month = d.getMonth();
System.log(d);
System.log(month);

我的输出如下:

[2015-04-01 09:24:53.012] [I] Wed Apr 01 2015 09:24:53 GMT-0400 (EDT)
[2015-04-01 09:24:53.012] [I] 3

底部输出不应该是4吗?

Shouldn't the bottom output be a 4?

提前致谢

推荐答案

这是一个数组。
月份以0开头,
所以你应该自己加1。

it is an array. month starts with 0, so you should plus 1 by yourself.

你可以看看这个:)

http://www.w3schools.com/jsref/jsref_getmonth .asp

这篇关于javascript getDate getMonth返回错误的月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆