為什么顯示的日期跟我的不一樣額?
var mydate=new Date();
var myyear=mydate.getFullYear();
document.write("年份:"+myyear+'<br>');
document.write('月:'+mydate.getMonth()+'<br>');
document.write('日:'+mydate.getDay()+'<br>');
document.write('時:'+mydate.getHours()+'<br>');
document.write('分:'+mydate.getMinutes()+'<br>');
document.write('秒:'+mydate.getSeconds());
獲得的日期時8月4號,可是今天是九月份啊
2017-09-07
mydate.getMonth()獲取的月份默認是減少一個月的,如果你要九月份,那就要mydate.getMonth()+1
2017-09-07
在這個里面默認的月份是從0開始的,是0——11月,所以+1即可?
2017-09-07
獲取月份要加1
獲取‘日’不是getDay, 而是 getDate
2017-09-07
好的?
謝謝