function getTimeRemaining(endtime) {
const total = Date.parse(endtime) - Date.parse(new Date());
const seconds = Math.floor((total / 1000) % 60);
const minutes = Math.floor((total / 1000 / 60) % 60);
const hours = Math.floor((total / (1000 * 60 * 60)) % 24);
const days = Math.floor(total / (1000 * 60 * 60 * 24));
return {
total,
days,
hours,
minutes,
seconds,
};
}
a = getTimeRemaining('2020-12-10 10:00:00');
console.log(a)
给定一个deadline,返回到当前的时分秒
最新推荐文章于 2022-10-25 17:49:21 发布