Skip to content
Merged
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
3 changes: 3 additions & 0 deletions Clock/aditya7302/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This project is a digital clock which uses basic html, css and js to display a clock on your web browser.
It is very simple to use and setup to display it you just need to click on the html file and it will start.
![ScreenShot](image.png)
61 changes: 61 additions & 0 deletions Clock/aditya7302/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
body{
margin: 0;
font-family: sans-serif;
display: flex;
flex-direction: column;
align-items: center;
height: 100vh;
justify-content: center;
background: url("https://plus.unsplash.com/premium_photo-1675368244123-082a84cf3072?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1250&q=80");
background-repeat: no-repeat;
background-size: cover;
overflow: hidden;
}

h2{
text-transform: uppercase;
letter-spacing: 4px;
font-size: 14px;
text-align: center;
color: white;
}

.clock{
display: flex;
}

.clock div{
margin: 5px;
position: relative;
}

.clock span{
width: 100px;
height: 80px;
background: slateblue;
opacity: 0.8;
color: white;
display: flex;
justify-content: center;
align-items: center;
font-size: 50px;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.clock .text{
height: 30px;
font-size: 10px;
text-transform: uppercase;
letter-spacing: 2px;
background: darkblue;
opacity: 0.8;
}

.clock #ampm{
position: absolute;
bottom: 0;
width: 60px;
height: 30px;
font-size: 20px;
background: green;
}
Binary file added Clock/aditya7302/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions Clock/aditya7302/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/styles.css">
<script defer src="index.js"></script>
<title>Digital Clock</title>
</head>
<body>
<h2>Digital Clock</h2>
<div class="clock">
<div>
<span id="hours">
00
</span>
<span class="text">
Hours
</span>
</div>
<div>
<span id="minutes">
00
</span>
<span class="text">
Minutes
</span>
</div>
<div>
<span id="seconds">
00
</span>
<span class="text">
Seconds
</span>
</div>
<div>
<span id="ampm">
AM
</span>
</div>
</div>
</body>
</html>
33 changes: 33 additions & 0 deletions Clock/aditya7302/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"use strict";

const hourEl = document.getElementById("hours");
const minuteEl = document.getElementById("minutes");
const secondEl = document.getElementById("seconds");
const ampmEl = document.getElementById("ampm");

const updateClock = () => {
let h = new Date().getHours();
let m = new Date().getMinutes();
let s = new Date().getSeconds();
let ampm = "AM";


if(h>12){
h -= 12;
ampm = "PM";
}

h = h<10 ? "0" + h: h;
m = m<10 ? "0" + m: m;
s = s<10 ? "0" + s: s;

hourEl.innerText = h;
minuteEl.innerText = m;
secondEl.innerText = s;
ampmEl.innerText = ampm;
setTimeout(() => {
updateClock();
},1000)
};

updateClock();