最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - setDate() returns number 1603240915215 instead of a date - Stack Overflow

programmeradmin0浏览0评论
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 to return a date but its not returnign a date instead it is returning a number 1603240915215

can some one help me to get the date instead of such number?

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 to return a date but its not returnign a date instead it is returning a number 1603240915215

can some one help me to get the date instead of such number?

Share Improve this question edited Nov 14, 2024 at 11:29 Roel 3,0962 gold badges32 silver badges35 bronze badges asked Oct 9, 2020 at 0:50 krunalkrunal 473 silver badges12 bronze badges 1
  • "supposed to return a date but its not returnign a date instead it is returning a number". That's not what the docs say developer.mozilla/en-US/docs/Web/JavaScript/Reference/… – JMadelaine Commented Oct 9, 2020 at 0:57
Add a ment  | 

2 Answers 2

Reset to default 4
const dateObj = new Date(1603240915215);

.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)

  1. 暂无评论