Search
 
SCRIPT & CODE EXAMPLE
 

CSS

next day 2pm delivery countdown timer script

if (document.getElementById('countdownTimer')) {
    pad = function(n, len) { // leading 0's
        var s = n.toString();
        return (new Array( (len - s.length + 1) ).join('0')) + s;
    };

    var timerRunning = setInterval(

        function countDown() {
            var target = 15; // 15:00hrs is the cut-off point
            var now = new Date();

            //Put this in a variable for convenience
            var weekday = now.getDay();

            if(weekday == 0){//Sunday? Add 24hrs
                target += 24;
            }

            if(weekday == 6){//It's Saturday? Add 48hrs
                target += 48;
            }

            //If between Monday and Friday, 
            //check if we're past the target hours, 
            //and if we are, abort.
            if((weekday>=1) && (weekday<=5)){
                if (now.getHours() > target) { //stop the clock
                    return 0;
                }                
            }

            var hrs = (target - 1) - now.getHours();
            if (hrs < 0) hrs = 0;
            var mins = 59 - now.getMinutes();
            if (mins < 0) mins = 0;
            var secs = 59 - now.getSeconds();
            if (secs < 0) secs = 0;

            var str = pad(hrs, 2) + ':' + pad(mins, 2) + '.<small>' + pad(secs, 2) + '</small>';
            document.getElementById('countdownTimer').innerHTML = str;

        }, 1000
    );
}
Comment

PREVIOUS NEXT
Code Example
Css :: horizontal scrollbar css style 
Css :: how to view only downloading speed in du meter 
Css :: how set image at top in wordpress 
Css :: grouping selector in css 
Css :: images css in react native fir in container 
Css :: jquery .css not working 
Css :: prevenrt div with height 100% from growing up 
Css :: which bootstrap css class will you use to put the navbar at the top of the page? feel free to check out the bootstrap website. 
Css :: css math functions simplifier 
Css :: border thickness css 
Css :: overwrite safari dropdown css 
Css :: invalid tailwind css classnames order 
Css :: nth master 
Css :: css different rules on different devices 
Css :: css animation cheat sheet 
Css :: google font family poppins 
Css :: count elements with css if only you have just 2 - no more or less 
Css :: advance logic in css 
Css :: tipografias family style para css y html 
Css :: css color properties 
Css :: how to apply a background image in css 
Css :: tailwind css 
Css :: css create array 
Typescript :: typescript sleep 
Typescript :: create-react-app typescript scss 
Typescript :: yarn typescript 
Typescript :: font awesome angular 
Typescript :: google sheets remove last character 
Typescript :: how to delete all elements from hashmap in java except one 
Typescript :: typescript initialize map inline 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =