JavaScript countdown timer code - Web Development and Web Design Codes


Wednesday, May 2, 2018

JavaScript countdown timer code

JavaScript countdown timer code

JavaScript countdown timer code
JavaScript countdown timer code
Hi Friends in JavaScript lesson we are going to learn how to create JavaScript countdown timer using Date Format..
you don't need to use any plugin or any third party can create JavaScript countdown timer easily and simply..  
just copy the below codes to create JavaScript countdown timer..

<title>JavaScript Countdown Timer Code</title>
function cdtd() {
 var xmas = new Date("December 24, 2018 00:01:00");
 var now = new Date();
 var timeDiff = xmas.getTime() - now.getTime();
 if (timeDiff <= 0) {
  document.write("Countdown Complete");
  // Run any code needed for countdown completion here
 var seconds = Math.floor(timeDiff / 1000);
 var minutes = Math.floor(seconds / 60);
 var hours = Math.floor(minutes / 60);
 var days = Math.floor(hours / 24);
 hours %= 24;
        minutes %= 60;
        seconds %= 60;
 document.getElementById("day").innerHTML = days;
 document.getElementById("hour").innerHTML = hours;
 document.getElementById("min").innerHTML = minutes;
 document.getElementById("sec").innerHTML = seconds;
 var timer = setTimeout('cdtd()',1000);
<h2 style="color:green">JavaScript Countdown Timer Code</h2>
Days Remaining:
<div id="day"></div>
Hours Remaining:
<div id="hour"></div>
Minutes Remaining:
<div id="min"></div>
Seconds Remaining:
<div id="sec"></div>

That's it Friends how to create JavaScript countdown timer..
thank for visiting..

No comments:

Post a Comment

Thank You for Your Comment

Note: Only a member of this blog may post a comment.