Скрипт обратного отсчёта

DzSoft

3T
Регистрация
13 Сен 2007
Сообщения
357
Реакции
295
Ребят, почему появляется + 30 дней в счетчике?
а если меняю дату. то у меня счётчик приходит к знаменателю 0
Код:
<script type="text/javascript">
                function CountdownTimer(elm,tl,mes){
this.initialize.apply(this,arguments);
}
CountdownTimer.prototype={
initialize:function(elm,tl,mes) {
  this.elem = document.getElementById(elm);
  this.tl = tl;
  this.mes = mes;
},countDown:function(){
  var timer='';
  var today=new Date();
  var day=Math.floor((this.tl-today)/(24*60*60*1000));
  var hour=Math.floor(((this.tl-today)%(24*60*60*1000))/(60*60*1000));
  var min=Math.floor(((this.tl-today)%(24*60*60*1000))/(60*1000))%60;
  var sec=Math.floor(((this.tl-today)%(24*60*60*1000))/1000)%60%60;
  var me=this;

  if( ( this.tl - today ) > 0 ){
   timer += '<span class="number-wrapper"><div class="line"></div><div class="caption">Дней</div><span class="number day">'+day+'</span></span>';
   timer += '<span class="number-wrapper"><div class="line"></div><div class="caption">Часов</div><span class="number hour">'+hour+'</span></span>';
   timer += '<span class="number-wrapper"><div class="line"></div><div class="caption">Минут</div><span class="number min">'+this.addZero(min)+'</span></span><span class="number-wrapper"><div class="line"></div><div class="caption">Секунд</div><span class="number sec">'+this.addZero(sec)+'</span></span>';
   this.elem.innerHTML = timer;
   tid = setTimeout( function(){me.countDown();},10 );
  }else{
   this.elem.innerHTML = this.mes;
   return;
  }
},addZero:function(num){ return ('0'+num).slice(-2); }
}
function CDT(){

// Set countdown limit
var tl = new Date(<?php
                            $m = JHtml::date($row->poduct_id->publish_down , 'm', true);
                            $y = JHtml::date($row->poduct_id->publish_down , 'Y', true);
                            $d = JHtml::date($row->poduct_id->publish_down , 'd', true)+2;
                            echo "$y,$m,$d"; ?>);

// You can add time's up message here
var timer = new CountdownTimer('CDT',tl,'<span class="number-wrapper"><div class="line"></div><span class="number end">Акция окончена!</span></span>');
timer.countDown();
}
window.onload=function(){
CDT();
}
</script>
Я полагаю всё настраивается в этих строках:
PHP:
// Set countdown limit
var tl = new Date(<?php
                            $m = JHtml::date($row->poduct_id->publish_down , 'm', true)-1; // убрал 30 дней
                            $y = JHtml::date($row->poduct_id->publish_down , 'Y', true);
                            $d = JHtml::date($row->poduct_id->publish_down , 'd', true)+1; // удаляю значение +1 и счётчик выводит 0
                            echo "$y,$m,$d"; ?>);
 
Последнее редактирование:
опишите подробней проблему, что значит +30 дней? Что именно вам нужно настроить?
 
Назад
Сверху