我正在尝试获取特定日期的确切秒数、分钟数等。这听起来可能很愚蠢,但为什么结果翻了一番?这似乎不对,是吗?
setInterval(function() {
var startDate = new Date(),
startDateTime = startDate.getTime(),
endDate = new Date(2012, 5, 14),
endDateTime = endDate.getTime();
var timeLeft = endDateTime - startDateTime;
var seconds = Math.round(timeLeft / 1000),
minutes = Math.round(seconds / 60),
hours = Math.round(minutes / 60),
days = Math.round(hours / 24),
weeks = Math.round(days / 7);
console.log(weeks, days, hours, minutes, seconds);
}, 1000);