const date = new Date(); const [month, day, year] = [date.getMonth(), date.getDate(), date.getFullYear()]; console.log(month, day, year);
La consola muestra una fecha anterior a la mía. ¿Es este el error del código VS?
Verifique la fecha y la hora de su sistema. JavaScript elige el valor de fecha de la hora del sistema.
day == date.getDate() pero realMonth != month == date.getMonth() porque el número de mes se da entre 0 y 11.
day == date.getDate()
realMonth != month == date.getMonth()
mdn getMonth() volver