HOW TO COUNTDOWN, 24HOUR AND RULES FOR WEEKENDS IN JQUERY?

lois waisbrooker

Total Post:70

Points:494
Posted by  lois waisbrooker
 823  View(s)
Ratings:
Rate this:

Ive added the code in here When it hits friday after 11.00 it should countdown to money @ 11.00 Any suggestions / help to get here? Also: The CountDown-timer should also be able to check if its a holiday here in Denmark (not sure about this function, maybe a database to control that part, because the holidays will come in variables hmm?)

HTML:

<div id="countdown"></div>

JavaScript

function ShowTime() {

    var now = new Date();

    if (now.getHours() > 11) {

        var hrs = 11 - now.getHours() + 24;

    } else {

        var hrs = 11 - now.getHours();

    }

    var mins = 60 - now.getMinutes();

    var secs = 60 - now.getSeconds();

 

    timeLeft = "You now have " + hrs + ' Hour(s) ' + mins + ' minuts ' + secs + ' seconds' + " To complete the order, and make sure the delivery will reach to you in 1-3 days";

    $("#countdown").html(timeLeft);

}

 

var countdown;

 

function StopTime() {

    clearInterval(countdown);

 

}

 

setInterval(ShowTime, 1000);

  1. Elena Glibart

    Post:42

    Points:296
    Re: How to countdown, 24hour and rules for weekends in jquery?

    I am not sure this is you want. Please check the code once.

    Javascript:

    function ShowTime() {

      var now = new Date();

        if (now.getHours() > 11){

            var hrs =11-now.getHours()+24;

            if(now.getDay() == 5){

                var hrs = hrs + 48;

            }

        }else{

      var hrs = 11-now.getHours();

             }

     

      var mins = 60-now.getMinutes();

      var secs = 60-now.getSeconds();

     

          timeLeft = "You now have "+hrs+' Hour(s) '+mins+' minuts '+secs+' seconds' +" To complete the order, and make sure the delivery will reach to you in 1-3 days";

      $("#countdown").html(timeLeft);

    }

     

    var countdown;

    function StopTime() {

        clearInterval(countdown);

     

    }

     

    setInterval(ShowTime ,1000); 

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!