admin管理员组文章数量:1026912
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
2 Answers
Reset to default 4const 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());
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
2 Answers
Reset to default 4const 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());
本文标签: javascriptsetDate() returns number 1603240915215 instead of a dateStack Overflow
版权声明:本文标题:javascript - setDate() returns number 1603240915215 instead of a date - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745653413a2161453.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论