html - Creating Countdown with Javascript -


this question has answer here:

i need create countdown runs daily 8am 8pm monday-friday , 8am-6pm saturday , sunday , when it's finished, says 'we open tomorrow @ 8am!'

how can achieve this?

website: (you can see countdown be.)

http://www.securemyhome.com/test-pulse3

html

 <div class="wereopen"><span class="blue">we'll call you!</span><br />only   <span class="countdown">  <!--  countdown banner  -->         7 hours          35 minutes  </span> left!</div> 

here's few i've tried.

var count=30;  var counter=setinterval(timer, 1000); //1000  run every 1 second  function timer() { count=count-1; if (count <= 0) {  clearinterval(counter);  //counter ended, here  return;  }   //do code showing number of seconds here  } 

2

 function countdown(options) {   var timer,  instance = this,    seconds = options.seconds || 10,  updatestatus = options.onupdatestatus || function () {},  counterend = options.oncounterend || function () {};   function decrementcounter() {  updatestatus(seconds);  if (seconds === 0) {   counterend();   instance.stop();    }    seconds--;   }    this.start = function () {   clearinterval(timer);    timer = 0;   seconds = options.seconds;   timer = setinterval(decrementcounter, 1000);   };    this.stop = function () {    clearinterval(timer);   };  } 

since ripping apart , being of no help, here's code similar may want. adjust accordingly.

// 24 hour based var targethour = 10;  var currenttime = new date();  // sun 0 mon 1 ... fri 5 sat 6 var currentday = currenttime.getday();  var offset = 24;                 // friday if (currentday === 5) {     offset = 60; }              // saturday else if(currentday === 6) {                                                                        offset = 48; }  if(currenttime.gethours() > targethour) {     console.log('hours:', (targethour + offset) - currenttime.gethours() - 1);     console.log('minutes:', 60 - currenttime.getminutes()); }  else if(currenttime.gethours() < targethour) {     console.log(targethour - currenttime.gethours() - 1);     console.log('minutes:', 60 - currenttime.getminutes()); }  

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -