<https://www.exeideas.com/2020/12/simple-countdown-timer-using-pure-javascript.html#BlogPosting>
<http://schema.org/articleBody>
"Countdown timers can serve many purposes. They can communicate to a user how long they’ve been doing something or how much time until some event happens, like the launch of your new website. In the sales and marketing context, they can create a sense of urgency to encourage conversion.Sometimes, you’re going to need to build a JavaScript countdown clock. You may have an event, a sale, a promotion, or a game. You can build a clock in raw JavaScript rather than reaching for the nearest plugin. While there are many great clock plugins, here are the benefits you’ll get from using raw JavaScript:There are many code snippets available online or on many other blogs and websites but everyone is not able to optimize your blog or website so you need some optimized code snippet. So now checkout out the code snippet for your blog and website that will give you all features for your desired code. Now grab the ready to use code and paste it where you want.CLICK HERE TO SEE DEMOFeatures:Set a valid end date.Calculate the time remaining.Convert the time to a usable format.Output the clock data as a reusable object.Display the clock on the page, and stop the clock when it reaches zero.Your code will be lightweight because it will have zero dependencies.Your website will perform better. You won’t need to load external scripts and stylesheets.You’ll have more control. You will have built the clock to behave exactly the way you want it to (rather than trying to bend a plugin to your will). .IRPP_ruby , .IRPP_ruby .postImageUrl , .IRPP_ruby .centered-text-area { height: 130px; position: relative; } .IRPP_ruby , .IRPP_ruby:hover , .IRPP_ruby:visited , .IRPP_ruby:active { border:0!important; } .IRPP_ruby .clearfix:after { content: \"\"; display: table; clear: both; } .IRPP_ruby { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #2C3E50; } .IRPP_ruby:active , .IRPP_ruby:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #34495E; } .IRPP_ruby .postImageUrl { background-position: center; background-size: cover; float: right; margin: 0; padding: 0; width: 31.59%; } .IRPP_ruby .centered-text-area { float: left; width: 65.65%; padding:0; margin:0; } .IRPP_ruby .centered-text { display: table; height: 130px; right: 0; top: 0; padding:0; margin:0;float: left;width: 100%; } .IRPP_ruby .IRPP_ruby-content { display: table-cell; margin: 0; padding: 0 0px 0 74px; position: relative; vertical-align: middle; width: 100%; } .IRPP_ruby .ctaText { border-bottom: 0 solid #fff; color: #F1C40F; font-size: 13px; font-weight: bold; margin: 0; padding: 0; } .IRPP_ruby .postTitle { color: #ECF0F1; font-size: 16px; font-weight: 600; margin: 0; padding: 0; } .IRPP_ruby .ctaButton { background: url(https://www.exeideas.com/wp-content/plugins/intelly-related-posts-pro/assets/images/next-arrow.png)no-repeat; display: inline-block; height: 130px; width: 54px; } .IRPP_ruby .ctaButton { background-color: inherit; margin-left: 10px; position: absolute; left: 0; top: 0; } .IRPP_ruby:after { content: \"\"; display: block; clear: both; } Recommended For You:Use CSS3/HTML5 Outlines To Upgrade Your WebsiteHow To Create A Simple Countdown Timer Using Pure JavaScript?There are few easy and understandable steps to achieve your desired functionality using pure Vanilla JavaScript that we are gonna share below. Follow each step perfectly.HTML:&lt;h1&gt;Countdown Clock&lt;/h1&gt;&lt;div id=\"clockdiv\"&gt;&lt;div&gt;&lt;span class=\"days\" id=\"day\"&gt;&lt;/span&gt;&lt;div class=\"smalltext\"&gt;Days&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=\"hours\" id=\"hour\"&gt;&lt;/span&gt;&lt;div class=\"smalltext\"&gt;Hours&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=\"minutes\" id=\"minute\"&gt;&lt;/span&gt;&lt;div class=\"smalltext\"&gt;Minutes&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=\"seconds\" id=\"second\"&gt;&lt;/span&gt;&lt;div class=\"smalltext\"&gt;Seconds&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;CSS:&lt;style type=\"text/css\"&gt;h1{color: #396;font-weight: 100;font-size: 40px;margin: 40px 0px 20px;}#clockdiv{font-family: sans-serif;color: #fff;display: inline-block;font-weight: 100;text-align: center;font-size: 30px;}#clockdiv &gt; div{padding: 10px;border-radius: 3px;background: #00BF96;display: inline-block;}#clockdiv div &gt; span{padding: 15px;border-radius: 3px;background: #00816A;display: inline-block;}smalltext{padding-top: 5px;font-size: 16px;}&lt;/style&gt;JavaScript:&lt;script type=\"text/javascript\"&gt;var deadline = new Date(\"dec 31, 2021 21:59:59\").getTime();var x = setInterval(function() {var now = new Date().getTime();var t = deadline - now;var days = Math.floor(t / (1000 * 60 * 60 * 24));var hours = Math.floor((t%(1000 * 60 * 60 * 24))/(1000 * 60 * 60));var minutes = Math.floor((t % (1000 * 60 * 60)) / (1000 * 60));var seconds = Math.floor((t % (1000 * 60)) / 1000);document.getElementById(\"day\").innerHTML =days ;document.getElementById(\"hour\").innerHTML =hours;document.getElementById(\"minute\").innerHTML = minutes;document.getElementById(\"second\").innerHTML =seconds;if (t &lt; 0) {clearInterval(x);document.getElementById(\"demo\").innerHTML = \"TIME UP\";document.getElementById(\"day\").innerHTML ='0';document.getElementById(\"hour\").innerHTML ='0';document.getElementById(\"minute\").innerHTML ='0' ;document.getElementById(\"second\").innerHTML = '0'; }}, 1000);&lt;/script&gt;Customization:Just change the ending date and time in JavaScript cod where dec 31, 2021 21:59:59a  is written. Rest contact form more.Troubleshooting the ErrorsDo it with concentration and patience. Check your alls steps and again and all codes or scripts. If you find any error you can contact us anytime via comment or better via email, We are always here to help you. .IRPP_ruby , .IRPP_ruby .postImageUrl , .IRPP_ruby .centered-text-area { height: 130px; position: relative; } .IRPP_ruby , .IRPP_ruby:hover , .IRPP_ruby:visited , .IRPP_ruby:active { border:0!important; } .IRPP_ruby .clearfix:after { content: \"\"; display: table; clear: both; } .IRPP_ruby { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #2C3E50; } .IRPP_ruby:active , .IRPP_ruby:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #34495E; } .IRPP_ruby .postImageUrl { background-position: center; background-size: cover; float: right; margin: 0; padding: 0; width: 31.59%; } .IRPP_ruby .centered-text-area { float: left; width: 65.65%; padding:0; margin:0; } .IRPP_ruby .centered-text { display: table; height: 130px; right: 0; top: 0; padding:0; margin:0;float: left;width: 100%; } .IRPP_ruby .IRPP_ruby-content { display: table-cell; margin: 0; padding: 0 0px 0 74px; position: relative; vertical-align: middle; width: 100%; } .IRPP_ruby .ctaText { border-bottom: 0 solid #fff; color: #F1C40F; font-size: 13px; font-weight: bold; margin: 0; padding: 0; } .IRPP_ruby .postTitle { color: #ECF0F1; font-size: 16px; font-weight: 600; margin: 0; padding: 0; } .IRPP_ruby .ctaButton { background: url(https://www.exeideas.com/wp-content/plugins/intelly-related-posts-pro/assets/images/next-arrow.png)no-repeat; display: inline-block; height: 130px; width: 54px; } .IRPP_ruby .ctaButton { background-color: inherit; margin-left: 10px; position: absolute; left: 0; top: 0; } .IRPP_ruby:after { content: \"\"; display: block; clear: both; } Recommended For You:Secure Your WebPage From Being Iframed In Others SiteFinal Words:That’s all we have. We hope that you liked this article. If you have any problem with this code in your template then feel free to contact us with a full explanation of your problem. We will reply to you as time allows us or If you have any doubts and problems please comment below. We are happy to help you! If you liked this article, Don’t forget to share this with your friends so they can also take benefit from it and leave your precious feedback in our comment form below. Happy development, See you in the next article."
<https://www.exeideas.com/2020/12/simple-countdown-timer-using-pure-javascript.html>