setDate() returns number 1603240915215 instead of a date

前端 未结 2 1543
萌比男神i
萌比男神i 2021-01-27 21:08
const date = new Date(\'August 19, 2020 23:15:30\');
const event = new Date();
  console.log(`event.setDate(date.getDate() + 1));

this code is supposed

相关标签:
2条回答
  • 2021-01-27 21:21
    const dateObj = new Date(1603240915215);
    
    0 讨论(0)
  • 2021-01-27 21:22

    .setDate return milliseconds. You want to access the dateInstance instead:

    const day = new Date('August 19, 2020 23:15:30'), nextDay = new Date();
    nextDay.setDate(day.getDate()+1); console.log(nextDay.toString());

    0 讨论(0)
提交回复
热议问题