shijian() {
const EndTIME = new Date(開始時間變量); // 截止時間
const NowTime = new Date(); // 開始時間
const usedTime = EndTIME - NowTime; // 相差的毫秒數(shù)
const days = Math.floor(usedTime / (24 * 3600 * 1000)); // 計算出天數(shù)
const leavel = usedTime % (24 * 3600 * 1000); // 計算天數(shù)后剩余的時間
const hours = Math.floor(leavel / (3600 * 1000)); // 計算剩余的小時數(shù)
const leavel2 = leavel % (3600 * 1000); // 計算剩余小時后剩余的毫秒數(shù)
const minutes = Math.floor(leavel2 / (60 * 1000)); // 計算剩余的分鐘數(shù)
const leavel3 = leavel2 % (60 * 1000);
const seconds = Math.round(leavel3 / 1000);
this.day = days < 10 ? `0${days}` : days;
this.hour = hours < 10 ? `0${hours}` : hours;
this.minutes = minutes < 10 ? `0${minutes}` : minutes;
this.second = seconds < 10 ? `0${seconds}` : seconds;
},
this.shijian();
setInterval(() => {
this.shijian();
}, 1000);
文章來源地址http://www.zghlxwxcb.cn/news/detail-723154.html
文章來源:http://www.zghlxwxcb.cn/news/detail-723154.html
到了這里,關(guān)于倒計時 天時分秒的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!