Tomorrow date 32 December

Hi,
this is my function to calculate the date of tomorrow (I need the format dd/mm)

const tomorrow = new Date();

let mese = tomorrow.getMonth() + 1;

let giorno = tomorrow.getDate() + 1;

if (mese < 10) {
    mese = "0" + mese
}
if (giorno < 10) {
    giorno = "0" + giorno
}

const giornoDom = giorno + "/" + mese;

node.status(giornoDom);

Worked fine for all the year but today ....

ssss

Where is the problem?

returns

the month for this date according to local time, as a zero-based value (where zero indicates the first month of the year)

returns

the day of the month for this date according to local time.

Your math is simply wrong. A better / correct way to achieve what you want:

const today = new Date()
const tomorrow = new Date(today)
tomorrow.setDate(tomorrow.getDate() + 1)
1 Like

Thank you very much ....

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.