daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (document.getElementById('countdownTimer')) {
  2.   pad = function(n, len) { // leading 0's
  3.     var s = n.toString();
  4.     return (new Array( (len - s.length + 1) ).join('0')) + s;
  5.   };
  6.  
  7.   var timerRunning = setInterval(
  8.     function countDown() {
  9.       var now = new Date();
  10.       if ( (now.getDay() >= 1) && (now.getDay() <= 5) ) { // Monday to Friday only
  11.         var target = 17; // 15:00hrs is the cut-off point
  12.         if (now.getHours() < target) { // don't do anything if we're past the cut-off point
  13.           var hrs = (target - 1) - now.getHours();
  14.           if (hrs < 0) hrs = 0;
  15.           var mins = 59 - now.getMinutes();
  16.           if (mins < 0) mins = 0;
  17.           var secs = 59 - now.getSeconds();
  18.           if (secs < 0) secs = 0;
  19.           var str = pad(hrs, 2) + ':' + pad(mins, 2) + '.<small>' + pad(secs, 2) + '</small>';
  20.           document.getElementById('countdownTimer').innerHTML = str;
  21.  
  22.         }
  23.       }
  24.     }, 1000
  25.   );
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top