const date = new Date(); const [month, day, year] = [date.getMonth(), date.getDate(), date.getFullYear()]; console.log(month, day, year);
The console is showing one day previous date of mine. Is this the mistake of VS code ?
Check your system's date & time. JavaScript picks date value from system time.
day == date.getDate() but realMonth != month == date.getMonth() because month number is given between 0 and 11.
day == date.getDate()
realMonth != month == date.getMonth()
mdn getMonth() return