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

const date = new Date('August 19, 2020 23:15:30');const event = new Date();console.log(event

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());

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745653414a4638399.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信