Skip to content
This repository was archived by the owner on Aug 20, 2024. It is now read-only.

clock #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

clock #148

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
35 changes: 35 additions & 0 deletions Javascript/Js clock/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">

<head>
<link rel="stylesheet" href="./style.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>JS Clock</title>
</head>

<body>

<div id='date'></div>
<h2 class="digital"></h2>


<div class="clock">

<div class="clockface">

<div class="hand hour-hand"></div>
<div class="hand min-hand"></div>
<div class="hand second-hand"></div>
</div>
<footer>
- By <a href="https://codepen.io/iambhadreshwara/">Jay Bhadreshwara</a>
</footer>


</div>

</body>

</html>
48 changes: 48 additions & 0 deletions Javascript/Js clock/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

const secondHand = document.querySelector('.second-hand');
const minHand = document.querySelector('.min-hand');
const hourHand = document.querySelector('.hour-hand');
const digital = document.querySelector('.digital');
function setDate(){



const now = new Date();
const day = now.getDay();
const daylist = ["Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday",
"Saturday"]
console.log("Today is " + daylist[day] + ".")

const seconds = now.getSeconds();
const secondDegree = ((seconds / 60) * 360 + 90) ;
secondHand.style.transform =`rotate(${secondDegree}deg)`;

const minutes = now.getMinutes();
const minuteDegree = ((minutes / 60) * 360 + 90) ;
minHand.style.transform =`rotate(${minuteDegree}deg)`;

const hours = now.getHours();
const hourDegree = ((hours / 12) * 360 + 90) ;
hourHand.style.transform =`rotate(${hourDegree}deg)`;
var ampm = "AM";
if(hours < 12){
ampm = "AM";
}
if(hours >= 12){

ampm = "AM";
}
if(seconds < 10){
seconds = "0"+ seconds;
}

if(minutes < 10){
minutes = "0"+ minutes;
}
document.getElementById('date').innerHTML = daylist[day];
digital.innerHTML = hours +" : "+ minutes +" : "+seconds;

}

setInterval(setDate,1000);
81 changes: 81 additions & 0 deletions Javascript/Js clock/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
@import url(https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300);
* {
box-sizing: border-box;
}
body {
background-image: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%);
height: 100vh;
}

.clock {
border: 3px solid white;
border-radius: 50%;
width: 15em;
height: 15em;
margin: 60px auto;
position: relative;
padding: 3rem;
background: pink;
box-shadow: 5px 9px 20px 0 rgba(0, 0, 0, 0.35);
}
.clockface {
width: 100%;
height: 100%;
position: relative;
transform: translateY(-3px);
}
.hand {
width: 50%;
height: 4px;
position: absolute;
top: 50%;
background: black;
transform-origin: 100%;
transform: rotate(90deg);
transition: all ease 0.8s;
}
.hour-hand {
width: 30%;
margin-left: 20%;
}
.min-hand {
width: 50%;
margin-left: 1%;
}
#date {
width: 100%;
position: relative;
top: 300px;
left: 7px;
text-align: center;
text-transform: uppercase;
letter-spacing: 5px;
color: black;
font-weight: bold;
font-size: 20px;
z-index: 2;
}
h2 {
width: 100%;
position: relative;
top: 191px;
left: 2px;
text-align: center;
text-transform: uppercase;
letter-spacing: 5px;
color: black;
font-size: 24px;
font-weight: bold;
z-index: 2;
}
footer {
width: 280px;
margin-top: 80px;
margin-left: -40px;
font-size: 24px;
color: black;
}
footer a {
text-decoration: none;
color: black;
}
Loading