📜  今天明天后天按钮html和javascript代码示例

📅  最后修改于: 2022-03-11 15:01:20.012000             🧑  作者: Mango

代码示例1
const tomorrow = new Date()
// add 1 day to today
tomorrow.setDate(new Date().getDate() + 1)
console.log(tomorrow) 

const dayAfterTomorrow = new Date()
// add 2 day to today
dayAfterTomorrow.setDate(new Date().getDate() + 2)
console.log(dayAfterTomorrow) 
//A date instance in JavaScript provides a .setDate() method to set the day of the month. A goody provided by this method: it automatically switches the month in case you’re exceeding the days in a month.
//At first, you need “today” as a reference. Use the new Date() constructor to create a date instance of today. Then, retrieving the day of tomorrow is a calculation of adding one day to the current day of the month using. You can retrieve the day of “today” using the .getDate() method.