Skip to content

Commit

Permalink
4th project added
Browse files Browse the repository at this point in the history
  • Loading branch information
ritesh1507 committed Jan 10, 2024
1 parent f0175d2 commit a83259c
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 4.Live-Digital-Clock/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<title>LiveDigitalClock</title>
</head>
<body>
<div id="container">
<div id="clock">
<label id="hourMin" style="font-size:56px; margin-top: -15px;"></label>
<label id="second"></label><label id="millisec"></label>
</div>
</div>
<script src="index.js"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions 4.Live-Digital-Clock/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

setInterval(update,1);

function update(){
let date=new Date();
function formatTime(date){
let hour=date.getHours();
let min=date.getMinutes();
if(min<10) return `${hour}:0${min}`;
return `${hour}:${min}`;
}

function formatSec(date){
let sec=date.getSeconds();
return `${sec}`;
}

function formatmillisec(date){
let ms=date.getMilliseconds();
return `${ms}`;
}

document.getElementById("hourMin").innerHTML=formatTime(date);
document.getElementById("second").innerHTML=formatSec(date);
document.getElementById("millisec").innerHTML=formatmillisec(date);

}
26 changes: 26 additions & 0 deletions 4.Live-Digital-Clock/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
body{
margin: 0;
background-color: rgb(247, 240, 222);
}
#container{
height: 110px;
margin-top: 150px;
background-color: rgba(107, 148, 171, 0.747);
}

#clock{
position: absolute;
margin-top: 10px;
display: flex;
flex-direction: column;
width: 15%;
height: 110px;
font-family: 'Orbitron', sans-serif;
background-color: rgba(103, 195, 134, 0.918);
text-align: center;
left: 50%;
transform: translateX(-50%);
justify-content: center;
border-radius: 15px;
box-shadow: 10px -10px rgba(107, 148, 171, 0.747),20px -20px rgba(107, 126, 144, 0.771);
}

0 comments on commit a83259c

Please sign in to comment.