function showTime(){
let time = Number.parseInt(new Date() / 1000)
//获取第二天时间
let timeSec = new Date(new Date().setHours(0, 0, 0, 0)) / 1000 + 86400;
let a = timeSec - time
let timer= setInterval(function(){
//时间一秒一秒递减
if(a>0){
a=a-1
let hours = Math.floor(a / 60 / 60 % 24); //获取小时
let minutes = Math.floor(a / 60 % 60); //获取分钟数
let seconds = Math.floor(a % 60); //获取秒
hours = timerFilter(hours)
minutes = timerFilter(minutes)
seconds = timerFilter(seconds)
var getTime = hours + ':' + minutes + ":" + seconds
$('.punch_time').html(getTime)
}else if(a<0){
clearInterval(timer);
}
},1000)
}
showTime()
//时间是一位数的时候,添加0
function timerFilter(params) {
if (params - 0 < 10) {
return '0' + params
} else {
return params
}
}