Home > DeveloperSection > Forums > How to countdown, 24hour and rules for weekends in jquery?
lois waisbrooker
lois waisbrooker

Total Post:70

Points:494
Posted on    January-28-2015 10:17 PM

 ASP.Net JQuery  JavaScript 
Ratings:


 1 Reply(s)
 573  View(s)
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);



Elena Glibart
Elena Glibart

Total Post:35

Points:128
Posted on    January-28-2015 10:42 PM

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); 


Don't want to miss updates? Please click the below button!

Follow MindStick