亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我正在處理 Javascript 日期,我堅持將日期添加 7 天

我正在處理 Javascript 日期,我堅持將日期添加 7 天

精慕HU 2023-03-03 10:04:43
 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)


查看完整回答
反對 回復 2023-03-03
  • 1 回答
  • 0 關注
  • 130 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號