var putYear=parseInt(prompt('请输入员工的入职年份'));
var putMonth=parseInt(prompt('请输入员工的入职年份'));
var putDate=parseInt(prompt('请输入员工入职时间'));
console.log(putYear,putMonth,putDate);
function allTime(a,b,c){
var newDate=new Date();
var outYear=newDate.setFullYear(a);
var outMonth=newDate.setMonth(b);
var outDate=newDate.setDate(c);
console.log(typeof outYear);
document.write('该员工入职时间是:'+outYear+'-'+outMonth+'-'+outDate+'<br/>');
document.write('该员工合同到期时间是:'+(outYear+3)+'-'+outMonth+'-'+outDate);
}
allTime(putYear,putMonth,putDate);如题。。。本来是想传入年月日的。但是结果却变成了很大的数字。麻烦学长们来看看~~~
1 回答
已采纳
西兰花伟大炮
TA贡献376条经验 获得超318个赞
<!doctype html> <html> <head> <meta charset="UTF-8" /> <title>Document</title> </head> <body> <script> var putYear=parseInt(prompt('请输入员工的入职年份')); var putMonth=parseInt(prompt('请输入员工的入职年份')); var putDate=parseInt(prompt('请输入员工入职时间')); console.log(putYear,putMonth,putDate); function allTime(a,b,c){ var newDate=new Date(a,b,c); var outYear=newDate.getFullYear(); var outMonth=newDate.getMonth(); var outDate=newDate.getDate(); console.log(typeof outYear); document.write('该员工入职时间是:'+outYear+'-'+outMonth+'-'+outDate+'<br/>'); document.write('该员工合同到期时间是:'+(outYear+3)+'-'+outMonth+'-'+outDate); } allTime(putYear,putMonth,putDate); </script> </body> </html>
望采纳,谢谢
添加回答
举报
0/150
提交
取消