问题:提交信息时要求将所选日期延后一天进行提交
解决过程:1.定义延后一天的计算方法,在提交前,将提交日期传入调用该方法
2.对延后的日期进行格式化,最后格式为yy-mm-dd
解决结果:
- const delayDay =(dates) => {
- dates = new Date(dates);
- dates = +dates + 1000*60*60*24;
- dates = new Date(dates);
- let year = d.getFullYear()
- let month = d.getMonth()+1
- let date = d.getDate()
- if (month >= 1 && month <= 9) {
- month = "0" + month;
- }
- if (date >= 1 && date <= 9) {
- date = "0" + date;
- }
- return year+"-"+month+"-"+date;
- }
- delayDay('2023-02-29')
- console.log(delayDay('2024-02-29'))//2024-03-01