我正在处理 Javascript 日期,我坚持将日期添加 7 天

 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 天


精慕HU
浏览 153回答 1
1回答

哈士奇WWW

var date = new Date();var first_date = new Date(date); //Make a copy of the date we want the first and last days fromfirst_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)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript