how to create watch in html
<!DOCTYPE html>
<html>
<head>
<title>Simple Clock</title>
<style>
#clock {
font-size: 2rem;
}
</style>
</head>
<body>
<div id="clock"></div>
<script>
function updateClock() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
document.getElementById('clock').textContent = `${hours}:${minutes}:${seconds}`;
}
// Update the clock every second
setInterval(updateClock, 1000);
// Initialize the clock
updateClock();
</script>
</body>
</html>
Simple Clock
<html>
<head>
<title>Simple Clock</title>
<style>
#clock {
font-size: 2rem;
}
</style>
</head>
<body>
<div id="clock"></div>
<script>
function updateClock() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
document.getElementById('clock').textContent = `${hours}:${minutes}:${seconds}`;
}
// Update the clock every second
setInterval(updateClock, 1000);
// Initialize the clock
updateClock();
</script>
</body>
</html>
कोई टिप्पणी नहीं