Home  • Programming • JavaScript

Make your digital clock with javascript

3049
<script>
function clock()
{
	var mydate=new Date();
	h=mydate.getHours();
	m=mydate.getMinutes();
	s=mydate.getSeconds();
	if(m<10)
	{
	m="0"+m
	}
	var suffix="AM";
	if(h>=12)
	{
	suffix="PM"
	h=h-12;
	}
	if(h==0)
	{
	h=12;
	}
	document.getElementById("clock").innerHTML=h+":"+m+":"+s+""+suffix;
}
function setTime()
	{
	setInterval("clock()",1000);
	}

</script>
<body bgcolor="mistyrose" onLoad="setTime()">
<h3>Digital Clock</h3>
<h1 id="clock">
</h1>

</body>

Comments 8


Very good work.Keep it up.
excellent tutorial.
fine we benifut it
Good. Go ahead.
Thumbs Up
wow
thank you for give it.Laughing
About Author
MD. IQBAL HOSSAIN
Copyright © 2025. Powered by Intellect Software Ltd