如何计算此语句
var dateTo = new Date(2019,04,03,3,15,0);
var countdown = Math.round((dateTo.getTime() - new Date().getTime()) / 1000);
答案 0 :(得分:0)
该值不是您所期望的吗? 尝试打印日期,并确保该值是您想要的值:
var dateTo = new Date(2019,04,03,3,15,0);
console.log(dateTo);
此外,最好只使用4和3,而不要使用“ 04”和“ 03”。
答案 1 :(得分:0)
这是你要去的吗?
#// Set the date we're counting down to
var countDownDate = new Date("Jan 5, 2021 15:37:25").getTime();
// Get todays date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
console.warn("val", days);