Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6993193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:44:00+00:00 2026-05-27T19:44:00+00:00

I have an annoying problem, i have trying to implement a simple 10 or

  • 0

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.

I found the below code Here 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?

<div id="countre3">Loading...</div>
<script type="text/javascript">
     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 && h==0 && m==0){
                return s+'sec';
             }else if(d==0){
                return h+'hrs '+m+'min '+s+'sec';
             }else if(d==0 && h==0){
                return m+'min '+s+'sec';
             }else {
                return ret;
             }
         }
         //
         var secArray = [];
         var dayNow = new Date().getDay();
         for(var i=0;i<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<secArray.length; i++){
                 var diff = secArray[i].sec-secNow;
                 if(diff>0){
                     nextIndex=i;
                     break;
                 }
             }
             //
             var diff=secArray[nextIndex].sec-secNow;
             var prevDiff=diff;
             if(diff<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, '<center><b>Next Turns are Due in </b><p class="smalltext"> @{countre}</center>', false] ]);
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:44:01+00:00Added an answer on May 27, 2026 at 7:44 pm

    Try this:

        function mycountre(countdownId, countdownSeconds, countdownLooping){
        var countre = document.getElementById(countdownId); // get html element
        if (!countre) {
            return;
        }
    
        var target = new Date().getTime() + 1000 * countdownSeconds; // target time
        var intervalId; // id of the interval
    
        // update function
        function updatecountre(){
            var time = Math.floor((target - new Date().getTime()) / 1000); // countdown time in seconds
            if (time < 0) { // if countdown ends
                if (countdownLooping) { // if it should loop
                    target += 1000 * countdownSeconds; // set new target time
                    time = Math.floor((target - new Date().getTime()) / 1000); // recalculate current time
                } else { // otherwise
                    clearInterval(intervalId); // clear interval
                    time = 0; // set time to 0 to avoid displaying negative values
                }
            }
    
            // split time to seconds, minutes and hours
            var seconds = '0' + (time % 60);
            time = (time - seconds) / 60;
            var minutes = '0' + (time % 60);
            time = (time - minutes) / 60;
            var hours = '0' + time;
    
            // make string from splited values
            var str = hours.substring(hours.length - 2) + ':' + minutes.substring(minutes.length - 2) + ':' + seconds.substring(seconds.length - 2);
            countre.innerHTML = str;
        }
    
        intervalId = setInterval(updatecountre, 200); // start interval to execute update function periodically
    };
    mycountre(
        'countre3', // id of the html element
        15 * 60, // time in seconds (15min here)
        true // loop after countdown ends?
    );
    

    Working demo: http://jsfiddle.net/Xv3jx/1/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem, simple and annoying. Im just trying to print a list of names, collected
I have an annoying CSS layout problem. I'm trying to float images on a
XML is cool in flex, but I have an annoying problem to solve, caused
I've recently begun learning C# but have encountered an annoying problem. Every variable I
I have a layout that is working, but it has one very annoying problem..
I have a very annoying problem and I'm trying to find the simplest solution
I have a weird, annoying problem with Python 2.6. I'm trying to run this
I have an annoying problem with mdb2 while trying to insert empty values in
I'm having a small but annoying problem with trying to open a link in
I have a pretty annoying compiling problem. I am trying to do a System.loadlibrary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.