How to make a digital clock using javascript
ADVERTISEMENTS
How to make a digital clock using javascript. In this program, you will learn how to make a digital clock using javascript.
Take an example through a javascript program:
<!-- How to make a digital clock using javascript -->
<!DOCTYPE html>
<html>
<style>
#frame {
width: auto;
height: auto;
border: 20px solid #263277;
display: inline-block;
padding: 20px 10px;
}
#timer {
font-size: 90px;
font-weight: 600;
}
</style>
<body>
<div id="frame">
<span id="timer"></span>
</div>
<script>
function watch() {
let d = new Date();
return (d.getHours() + " : " + d.getMinutes() + " : " + d.getSeconds());
}
(function(){
setInterval(function() {
document.getElementById("timer").innerHTML = watch();
}, 1000)
})();
</script>
</body>
</html>
Output:
18 : 39 : 14
Tags:
# javascript digital clock with date
# build a digital clock using javascript and HTML
# build a clock using javascript and HTML
# javascript digital clock source code