獲取當前時間和幾天後的時間格式yyyy-mm-dd

用JS獲取當前時間和之後幾天的時間

handleTime(day) {      
	console.log(new Date(new Date().setDate(new Date().getDate() + Number(day))).toJSON())  
	return new Date(new Date().setDate(new Date().getDate() + Number(day))).toJSON().split('T')[0]     
},
![打印的結果](https://img-blog.csdnimg.cn/20190529165441725.png)
new Date(new Date().setMonth(new Date().getMonth() - 1)).toJSON().split('T')[0]  // 獲取前一個月的時間

export const GET_NOW_TIME = new Date().toJSON().split('T')[0] // 獲取當前時間
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章