参数1:原日期如:2020-01-01
参数2:天数
export function addDate(date,days){
var d=new Date(date);
d.setDate(d.getDate()+days);
var m=d.getMonth()+1;
return d.getFullYear()+'-'+m+'-'+d.getDate();
}
本文介绍了一个简单的JavaScript函数,该函数能够将指定的日期加上或减去一定数量的天数,并返回新的日期格式为YYYY-MM-DD。通过这个函数,用户可以方便地进行日期运算。
参数1:原日期如:2020-01-01
参数2:天数
export function addDate(date,days){
var d=new Date(date);
d.setDate(d.getDate()+days);
var m=d.getMonth()+1;
return d.getFullYear()+'-'+m+'-'+d.getDate();
}
1042
1787

被折叠的 条评论
为什么被折叠?