Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

<!

DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=, initial-scale=">
<title>Clock</title>
<div ></div>
<h1 align="center">Government Ploytechnic Hingoli</h1>

<style>
body {
align-content: center;
margin: auto;
padding: auto;
box-sizing: border-box;
font-family: "Lato", sans-serif;
font-style: italic;
background: #14080e;
background-color: aliceblue;
scroll-behavior: auto;
width: 1200px;
border: 20px solid black;
padding: 25px;
margin: 25px;
}
#clock {
height: 100vh;
width: 100%;
background-color: white;
color: black;
display: flex;
align-items: center;
justify-content: center;
font-size: 100px;
font-style: Monospace;
background-size: cover;
}
</style>
</head>

<body>
<div id="clock">
</div>
<script>
function clock() {
let date = new Date();
let hrs = date.getHours();
let mins = date.getMinutes();
let secs = date.getSeconds();
let period = "AM";
if (hrs == 0) hrs = 12;
if (hrs > 12) {
hrs = hrs - 12;
period = "PM";
}
hrs = hrs < 10 ? `0${hrs}` : hrs;
mins = mins < 10 ? `0${mins}` : mins;
secs = secs < 10 ? `0${secs}` : secs;
let time = `${hrs}:${mins}:${secs} ${period}`;
setInterval(clock, 1000);
document.getElementById("clock").innerText = time;
}
clock();

</script>
</body>

</html>

You might also like