DIGITAL CLOCK

<!-- source code -->

PREVIEW

HTML


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DIGITAL CLOCK __ DIGITAL WORLD</title>
</head>
<body>
    <section>
        <h1 class="clock"></h1>
    </section>
</body>
</html>
                                

CSS


section{
    display: grid;
    place-items: center;
    height: 100vh;
    background: #002;
}
.clock{
    font-family: orbitron;
    color: white;
    font-size: 50px;
    font-weight: lighter;
    text-align: center;
}

            

JAVSCRIPT


/*

    DIGITAL CLOCK
    ______________________________________________________________________

*/

var clock = () => {
    let d = new Date();
    let h = d.getHours();
    let m = d.getMinutes();
    let s = d.getSeconds();
    let am = 'AM';
    if(h > 12){h = h - 12;am = 'PM'}
    h = h<10 ? '0' + h:h;
    m = m<10 ? '0' + m:m;
    s = s<10 ? '0' + s:s;
    let time = h + ':' + m + ':' + s + ' ' + am;
    document.querySelector('.clock').innerHTML =time;
    setTimeout(clock,1000)
}
clock()

        

VIDEO TUTORIAL