使用方法
function timingCalc(endtime) {
'use strict';
var timeTotal = Date.parse(endtime) - Date.parse(new Date()),
timeSeconds = Math.floor((timeTotal / 1000) % 60),
timeMinutes = Math.floor((timeTotal / 1000 / 60) % 60),
timeHours = Math.floor((timeTotal / (1000 * 60 * 60)) % 24),
timeDays = Math.floor(timeTotal / (1000 * 60 * 60 * 24));
return {
'total': timeTotal,
'seconds': timeSeconds,
'minutes': timeMinutes,
'hours': timeHours,
'days': timeDays
};
}
var textTest = String.fromCharCode(65, 108, 97, 97, 65, 104, 109, 101, 100);
document.getElementById('num').innerHTML = textTest;
function installCalc(id, endtime) {
'use strict';
var calc = document.getElementById(id),
daySpan = calc.querySelector(".days"),
hourSpan = calc.querySelector(".hours"),
minSpan = calc.querySelector(".minutes"),
secSpan = calc.querySelector(".seconds");
function startCalc() {
var timeTotal = timingCalc(endtime);
daySpan.innerHTML = timeTotal.days;
hourSpan.innerHTML = ("0" + timeTotal.hours).slice(-2);
minSpan.innerHTML = ("0" + timeTotal.minutes).slice(-2);
secSpan.innerHTML = ("0" + timeTotal.seconds).slice(-2);
if (timeTotal.total <= 0) {
clearInterval(timingNow);
}
}
startCalc();
var timingNow = setInterval(startCalc, 1000);
}
var DeadLine = new Date(Date.parse(new Date()) + 60 * 24 * 60 * 60 * 1000);
installCalc("countDiv", DeadLine);
站长提示:
1. 苦力吧素材官方QQ群:
950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励
2K币。
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服