最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin7PV0评论
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());

Post a comment

comment list (0)

  1. No comments so far