- <html>
- <head>
- <title> Countdown </title>
- <!--The following CSS styles--
- <style type= "Text/css">
- . Daojishi H2
- {
- Font-family:helvetica, Microsoft Yahei, Arial, Sans-serif;
- font-size:14px;
- margin-bottom:5px;
- Color: #151515;
- }
- . Daojishi #timer
- {
- Font-family:helvetica, Microsoft Yahei, Arial, Sans-serif;
- font-size:14px;
- Color: #151515;
- Font-weight:bold;
- }
- </style>
- <script type = "Text/javascript" src = "timer.js">
- </Script>
- </head>
- <body onload = "timer ()">
- <div class = "Daojishi">
- <h2> remaining time:</h2>
- <div id = "timer">
- </div>
- </div>
- </Body>
- </html>
- function timer ()
- {
- var ts = (new Date (2018, one, one, 9, 0, 0))-(new Date ()); Calculates the number of milliseconds remaining for the month minus one months
- var dd = parseint (TS/1000/60/60/24, 10); //Calculate the remaining days
- var hh = parseint (ts/1000/60/60% 24, 10); //Calculate the number of hours remaining
- var mm = parseint (ts/1000/60% 60, 10); //Calculate the number of minutes remaining
- var ss = parseint (ts/1000% 60, 10); //Calculate the number of seconds remaining
- DD = Checktime (DD);
- HH = Checktime (hh);
- MM = Checktime (mm);
- SS = Checktime (ss);
- document.getElementById ("Timer"). InnerHTML = dd + "Day" + hh + "when" + mm + "min" + ss + "SEC";
- SetInterval ("timer ()", 1000);
- }
- function Checktime (i)
- {
- if (i <) {
- i = "0" + i;
- }
- return i;
- }
JS Implementation Countdown