Skip to main content

 HOW TO MAKE TIME COUNTDOWN







BASIC NEEDS:

HARDWARE
1. COMPUTER/ LAPTOP

SOFTWARE
1. TEXT EDITOR
EXAMPLE: VISUAL STUDIO, ATOM, SUBLIME TEXT, NOTEPAD++  ETC...

HAVE A BASIC KNOWLEDGE
1. HTML5
2. CSS3
3. JAVASCRIPT

LET'S SEE OUTPUT IN VIDEOS:




HTML CODE:


<!-- DEVELOP BY DELHI KA CODER -->
<html>
    <title>Count-down develop by delhikacoder</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css"/>
 
    <script src="javascript.js" defer></script>

    <body>

        <section>
            <div class="delhikacoder">
                <h1> Time left in new year</h1></div>
            <div class="count-down-container ">
               

                <div class="days-c count-down-el">
                    <p class="big-text" id="days">0</p>
                    <span>Days</span>
                </div>

                <div class="hours-c count-down-el">
                    <p class="big-text" id="hours">0</p>
                    <span>Hours</span>
                </div>
                <div class="minutes-c count-down-el">
                    <p class="big-text" id="minutes">0</p>
                    <span>Minutes</span>
                </div>
                <div class="second count-down-el">
                    <p class="big-text" id="second">0</p>
                    <span>secondd</span>
                </div>

               
            </div>
        </section>
    </body>
</html>


CSS CODE:

/*DEVELOP BY DELHI KA CODER */

*{

    box-sizing: border-box;
    padding:0;
    margin0;
}
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,900;1
,900&display=swap');
body{
    background: cadetblue;
    font-family'Lato';
    background-image: url(hero-bg.jpg);
    background-position: center;
}
.delhikacoder{
    margin-top10%;
}
.count-down-container{
    display: flex;
    text-align: center !important;
    background: red;
    position: absolute;
    color: #fff;
    left19%;
}

.big-text{
    font-size4rem;
    margin0 2rem;
}
.count-down-el{
    text-align: center;
    
    margin:  0 2rem;
    padding9px 0;
}
.count-down-el span{
    text-align: center;
    font-size1.5rem;
}
h1{
    text-align: center;
    font-size43px;
    padding27px 0;
    color: #fff;
    font-weight800;
}

@media (max-width:768px){
    .count-down-container{
    display: inline;
  } 
  }

JAVSCRIPT CODE:


//DEVELOP BY DELHI KA CODER
const daysupdate = document.getElementById('days')
const hoursupdate = document.getElementById('hours')
const minutesupdate = document.getElementById('minutes')
const secondupdate  = document.getElementById('second')



const newYear = '1 jan 2022';
function countdown(){
    const newYearDate = new Date(newYear);
    const currentDate = new Date();
    const second = (newYearDate - currentDate) /1000;

    const days = Math.floor(second/3600/24);
    const hours = Math.floor(second/3600 )% 24;
    const minutes = Math.floor(second/60 )% 60;
    const totalsecond = Math.floor(second)% 60 ;
  
    
    
    

    daysupdate.innerHTML = formatTime(days);
    hoursupdate.innerHTML = formatTime(hours);
    minutesupdate.innerHTML = formatTime(minutes);
    secondupdate.innerHTML = formatTime(totalsecond); 
}

function formatTime(time){
   return time < 10 ? `0${time}` :time  ; 
}

countdown();
setInterval(countdown, 1000);


 


OUTPUT PHOTO:




Comments

Popular posts from this blog

 What is web designing? 1. web designing meant layout of a website   2. we can design a website layout on photoshop, figma, in design, xd,  Adobe Illustrator   software  3. when a design is ready and approved by the client then start front-end development  4. front-end developer mean to develop a layout design by web designers and how is looking layout on the web browswe   web designer skills 1. Adobe photoshop 2.  Adobe Illustrator 3.  Adobe InDesign 4. Figma 5. Adobe XD if you want to become a web designer so you know very well this software and anyone in you become a master like a pro all software is used for mobile application layout design and logo design and website layout design front-end developer skills 1.html5 (it is the latest version of Html) 2. css3 ( it is the latest version of css) 3. Bootstrap5 (it is the latest version of bootstrap) 3. javascript (ECMA6 it is the latest version of javascript) 4. lear javascript...
  Basic Navbar Toggle Basic Html Code source: <html>     <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1">     <link rel="stylesheet" href="style.css"/>     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" referrerpolicy="no-referrer" />     <title> slider</title> <body>     <section>         <nav>             <div class="logo">                 brand   logo             </div>             <div class="sidebar">             <i cla...