Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

added my code in javascript clock #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Upload Your Code/javascript clock/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"liveServer.settings.port": 5501,
"liveServer.settings.host": "192.168.1.78"
}
37 changes: 37 additions & 0 deletions Upload Your Code/javascript clock/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Clock</title>
</head>

<body>
<!-- <div class="loader"></div> -->
<div class="container">
<div class="Box">
<div id="head">
Indian Standard Time (UTC+5:30)
</div>
<div id="clock">
<div class="time">
<div id="time-div0" class="time-div"></div>
<div id="time-div1" class="time-div"></div>
<div id="time-div2" class="time-div"></div>
</div>
<div class="date">
<div id="date-div0" class="date-div"></div>
<div id="date-div1" class="date-div"></div>
<div id="date-div2" class="date-div"></div>
<div id="date-div3" class="date-div"></div>
</div>
</div>
</div>
</div>
<!-- Designed By Mahesh Semwal -->
<script src="script.js"></script>
</body>

</html>
34 changes: 34 additions & 0 deletions Upload Your Code/javascript clock/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// setTimeout(() => {
// window.addEventListener('load', function () {
// const loader = document.querySelector('.loader');
// loader.style.display = 'none';
// });
// }, 3000);

setInterval(ShowTime, 1000)
function ShowTime() {
let date = new Date()
let h = date.getHours();
let m = date.getMinutes();
let s = date.getSeconds();
let d = date.getDate();
let D = date.getDay();
let month = date.getMonth();
let year = date.getYear();
let a = document.getElementById("clock");
let days = ["Sunday", "Monday", "Tuesday", "wednesday", "Thursday", "Friday", "Saturday"]
let mon = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
document.getElementById("time-div0").innerHTML = h
document.getElementById("time-div1").innerHTML = m
document.getElementById("time-div2").innerHTML = s
document.getElementById("date-div0").innerHTML = days[D] + ","
document.getElementById("date-div1").innerHTML = d
document.getElementById("date-div2").innerHTML = mon[month]
document.getElementById("date-div3").innerHTML = year - 100
if (h >= 19 || h <= 5) {
let b = document.getElementsByClassName("time-div")
for (let i in b) {
b[i].style.boxShadow = "50px -20px 200px rgb(255, 255, 255) "
}
}
}
82 changes: 82 additions & 0 deletions Upload Your Code/javascript clock/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
body{
margin: 0;
padding: 0;
box-sizing: border-box;
height: 100vh;
width: 100%;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
background: rgb(41, 40, 40);
color: white;
}
.loader {

/* background-color: aliceblue; */
/* border: 4px solid #f3f3f3; */
/* cnter the .loader */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
border-top: 4px solid #3498db;
border-radius: 50%;
width: 30px;
height: 30px;
animation: spin 2s linear infinite;
position: absolute;
}

@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

.container{
/* border: 2px solid red; */
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
/* border: 2px solid red; */
/* border: 2px solid red; */
}

#head{
margin: 20px;
color: rgb(255, 255, 255);
}
.time,.date{
display: flex;
text-align: center;
justify-content: center;
}
.date{
justify-content: flex-end;
margin-right: 20px;
}
.date-div{
padding: 2px 5px;
}
.time-div{
width: 120px;
padding: 20px;
font-size: 100px;
background: rgb(26, 25, 25);
/* border: 1px solid black; */
box-shadow:
50px -20px 200px rgb(230, 222, 118)
}
#time-div0{
border-top-left-radius: 20px;
border-bottom-left-radius: 20px;
}
#time-div2{
border-top-right-radius: 20px;
border-bottom-right-radius: 20px;
}
/* #time-div1{
background-color: rgb(22, 22, 22);
box-shadow:
50px -20px 200px rgb(230, 222, 118)
} */