Digital Clock using HTML,CSS,JS.

 

Digital Clock using (HTML, CSS,  JS)



in This Tutorial you will Learn, How to Create Simple Digital Clock using HTML,CSS & Basics of Javascript 


in Javascript there is a build in object called Date(), And methodes of this object as Follows:

.getHours()

.getMinutes()

.getSeconds()

With help of these methodes, We will be available to get all required details to display Time along with it is also important to update the time after each interval, At Delay of 1 sec. for that purpose we use setTimeout() function form the Javascript.

GitHub Link (Source Code)

// Digital Clock

setInterval(()=>{
    let d=new Date();  // Creating Instance of Date Object
    let h=d.getHours();  // Getting Hours by calling .getHours()
    let m=d.getMinutes();// Getting Hours by calling .getHours()
    let s=d.getSeconds();// Getting Hours by calling .getHours()
    document.getElementById("hello").innerHTML=`${h} : ${m} : ${s}`
},1000);

Comments

Popular Posts