const date = new Date('August 19, 2020 23:15:30');
const event = new Date();
console.log(event.setDate(date.getDate() + 1));
此代码应该返回一个日期,但它不返回日期,而是返回一个数字 1603240915215
有人可以帮我获取日期而不是这样的数字吗?
const dateObj = new Date(1603240915215);
.setDate
返回毫秒。您想改为访问 dateInstance:
const day = new Date('August 19, 2020 23:15:30'), nextDay = new Date();
nextDay.setDate(day.getDate()+1); console.log(nextDay.toString());