Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created Countdowm app #1

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
Binary file added CountDown App/Images/bg1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions CountDown App/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">

</head>
<body>
<h1>New Years Eve</h1>
<div class="con">
<!-- inside it we have days , hours , min and Sec Container -->
<div class="whole-elem days-con">
<p class="big-text" id="days">0</p>
<span>Days</span>
</div>
<div class="whole-elem hours-con">
<p class="big-text" id="hours">0</p>
<span>Hours</span>
</div>
<div class="whole-elem mins-con">
<p class="big-text" id="mins">0</p>
<span>Minutes</span>
</div>
<div class="whole-elem seconds-con">
<p class="big-text" id="sec">0</p>
<span>Seconds</span>
</div>


</div>
<script src="script.js"></script>
</body>
</html>
36 changes: 36 additions & 0 deletions CountDown App/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
let daysEl = document.getElementById('days');
let hourEl = document.getElementById('hours');
let minEl = document.getElementById('mins');
let secEl = document.getElementById('sec');


function countdown(){

var currentTime= new Date().getTime(); // Curent Time
const newYear = new Date("dec 31, 2022 23:59:59").getTime(); // destination time

var difference = newYear - currentTime;
// you have got the answere but in milliseconds

var seconds,hours,days,minutes;
seconds = Math.floor((difference%(1000*60)/1000));
minutes = Math.floor(difference%(1000*60*60)/(1000*60));
hours = Math.floor((difference%(1000*60*60*24))/(1000*60*60));
days = Math.floor(difference/(1000*60*60*24));

daysEl.innerHTML = days;
hourEl.innerHTML =Timeformat(hours);
minEl.innerHTML = Timeformat(minutes);
secEl.innerHTML = Timeformat(seconds);

};

function Timeformat (time) {
if(time < 10)
return (`0${time}`);
else
return time;
}

setInterval(countdown,1000) //Updtaes the function every 1 sec
// 1000ms = 1 sec
48 changes: 48 additions & 0 deletions CountDown App/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;1,200&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@1,500&display=swap');




*{
box-sizing: border-box;
}

body{
margin: 0px;
background: url('Images/bg1.jpg') no-repeat;
background-size: cover;
/* background-position: center center; */
min-height: 100vh;
font-family: 'Poppins', sans-serif;
display: flex;
flex-direction: column;
align-items: center;

}
h1{

font-size: 4.2rem;
font-weight: 400;
margin-top: 5rem;
}

.whole-elem{
text-align: center;
}

.con{
display: flex;
/* border: 5px solid #ffffff9c;
padding: 15px 70px ; */
}

.big-text{
text-align: center;
font-size: 6rem;
margin: 0px 60px;
}

.whole-elem span{
font-size: 1.7rem;
}