(function ($){
$(".count-down").each(function (){
const endTime=new Date($(this).data('date')).getTime();
const endtext=$(this).data('end');
const counter=$(this);
const daystxt=counter.data('days');
const hourstxt=counter.data('hours');
const minutestxt=counter.data('minutes');
const secondstxt=counter.data('seconds');
setInterval(()=> {
const now=new Date().getTime();
const timeLeft=endTime - now;
if(timeLeft > 0){
const days=String(Math.floor(timeLeft / (1000 * 60 * 60 * 24))).padStart(2, '0');
const hours=String(Math.floor((timeLeft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, '0');
const minutes=String(Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0');
const seconds=String(Math.floor((timeLeft % (1000 * 60)) / 1000)).padStart(2, '0');
counter.html(`
<div class="days"><div><b>${days}</b><span>${daystxt}</span></div></div>
<div class="hours"><div><b>${hours}</b><span>${hourstxt}</span></div></div>
<div class="minutes"><div><b>${minutes}</b><span>${minutestxt}</span></div></div>
<div class="seconds"><div><b>${seconds}</b><span>${secondstxt}</span></div></div>
`);
}else{
counter.html(`<span class="end">${endtext}</span>`);
}}, 1000);
});
})(jQuery);