var date = new Date(); var first_date = new Date(date); //Make a copy of the date we want the first and last days from first_date.setUTCDate(1); //Set the day as the first of the month var firstDay = first_date.toJSON().substring(0, 10); console.log(firstDay)我正在处理 Javascript 日期,我坚持在这个日期上添加 7 天
1 回答

哈士奇WWW
TA贡献1799条经验 获得超6个赞
var date = new Date();
var first_date = new Date(date); //Make a copy of the date we want the first and last days from
first_date.setUTCDate(1); //Set the day as the first of the month
var firstDay = first_date.toJSON().substring(0, 10);
var resultDate = new Date();
resultDate.setDate(first_date.getDate() + 7);
var resultDay = resultDate.toJSON().substring(0, 10);
console.log("First day: " + firstDay)
console.log("7 days from specific day: " + resultDay)
添加回答
举报
0/150
提交
取消