为什么月份+多了一个1?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <!DOCTYPE html> < html > < head lang = "en" > < meta charset = "UTF-8" > < title >员工合同到期时间</ title > </ head > < body > < script > var useryears=prompt("请输入员工的入职年份"), userMoth=prompt("请输入员工的入职月份"), userDate=prompt("请输入员工的入职时间"); function timeGo(years,moth,date){ var today=new Date(years,moth,date); document.write("该员工入职时间是:"+today.getFullYear()+"-"+(today.getMonth()+1)+"-"+today.getDate()+"< br >") document.write("该员工合同到期时间是:"+(today.getFullYear()+3)+"-"+(today.getMonth()+1)+"-"+today.getDate()) } timeGo(useryears,userMoth,userDate) //?代码补充 </ script > </ body > </ html > |
获取的月份不是0-11吗 不是要加1才正确吗?对比了一下其他同学的代码+1获取的月份是正确的,为什么我+1获取的月份会多了1.另外代码中还有别的问题吗?
19
收起
正在回答 回答被采纳积分+1
3回答
相似问题
登录后可查看更多问答,登录/注册
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧