title: Recurrent Javascript countdown
body: <p>I have an annoying problem, i have trying to implement a simple 10 or 15 minute recurrent countdown. i have tried jQuery but it just gives me options to count down to a date and stops after the countdown is finished.</p>
  
  <p>I found the below code <a href="http://www.dynamicdrive.com/forums/showthread.php?t=45319" rel="nofollow">Here</a> but i cant figure it to remove the days and make it to count down for 10 or 15 minuters. Can someone please help me?</p>
  
  <pre><code>&lt;div id="countre3"&gt;Loading...&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
       function mycountre(o, timeArray){
           var countre = document.getElementById(o);
           if(!countre) {
               return;
           }
  
           // helper functions
           function mksec(day, h, m, s){ return day*24*60*60+h*60*60+m*60+s; }
           function toTimeString(sec, showZero){
               var d=Math.floor(sec/(60*60*24))
               var h=Math.floor(sec/(60*60)%24);
               var m=Math.floor((sec/60) % 60);
               var s=sec % 60;
               var ret=d+'days '+h+'hrs '+m+'min '+s+'sec';
               if(showZero){
                  return ret;
               }else if(d==0 &amp;&amp; h==0 &amp;&amp; m==0){
                  return s+'sec';
               }else if(d==0){
                  return h+'hrs '+m+'min '+s+'sec';
               }else if(d==0 &amp;&amp; h==0){
                  return m+'min '+s+'sec';
               }else {
                  return ret;
               }
           }
           //
           var secArray = [];
           var dayNow = new Date().getDay();
           for(var i=0;i&lt;timeArray.length;i++){
              var day=timeArray[i][0];
              if(day==-1){
                  day=dayNow;
              }
               secArray.push({
                  day: timeArray[i][0],
                  sec: mksec(day, timeArray[i][2], timeArray[i][2], timeArray[i][3]),
                  msg: timeArray[i][4] || false,
                  showZero: timeArray[i][5] || false
               });
           }
           secArray.sort(function(a,b){ return a.sec-b.sec;});
  
           // timer code - will be called around each second (~1000 ms)
           function updatecountre(){
               // get current UTC time in seconds
               var d=new Date();
               var secNow = mksec(d.getDay(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds());
               // find next event
               var nextIndex=0;
               for(var i=0;i&lt;secArray.length; i++){
                   var diff = secArray[i].sec-secNow;
                   if(diff&gt;0){
                       nextIndex=i;
                       break;
                   }
               }
               //
               var diff=secArray[nextIndex].sec-secNow;
               var prevDiff=diff;
               if(diff&lt;0){
                  var dayDiff = 6-secArray[nextIndex].day;
                  if(secArray[nextIndex].day == -1){
                      dayDiff=0;
                  }
                  diff=(dayDiff+1)*24*60*60-Math.abs(diff);
               }
               var str='';
               // get message if there is any set
               if(secArray[nextIndex].msg){
                   str=secArray[nextIndex].msg;
               }
               var timeString = toTimeString(diff, secArray[nextIndex].showZero);
               if(str.match('@{countre}')!=null){
                   str=str.replace(/@{countre}/, timeString);
               }else if(str.indexOf(' ')==0){ // message starts with space
                   str=timeString+str;
               }else{ // no specific hint where to put countre, so display it after message
                   str+=timeString;
               }
               countre.innerHTML=str;
          }
  
           setInterval(updatecountre, 1000);
  
       };
  mycountre('countre3', [ [5, 5, 0, 0, '&lt;center&gt;&lt;b&gt;Next Turns are Due in &lt;/b&gt;&lt;p class="smalltext"&gt; @{countre}&lt;/center&gt;', false] ]);
  &lt;/script&gt;
  </code></pre>