Skip to content

Basic digital watch looking great just in 15 lines of code #17

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
72 changes: 72 additions & 0 deletions digital-watch.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!DOCTYPE html>
<html lang="en">

<head>
<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>Digital Watch</title>
<style>
body {
background: #333;
text-align: center;
}

#greeting {
color: white;
font-family: Arial;
font-size: 1.6em;
margin-top: 50px;
margin-bottom: 10px;
}

#message {
margin-top: 10px;
font-family: Arial;
font-size: 3.5em;
color: white;
}

.clock {
font-size: 4em;
text-align: center;
margin: 80px auto;
color: red;
font-family: Arial;
}

.clock span {
padding: 20px;
background: #260C0C;
width: 250px;
height: 150px;
}
</style>
</head>

<body>
<p id="greeting">Hello Aspiring World Class Developers</p>
<p id="message">Here you go! Enjoy Your Digital Watch</p>
<div class="clock"></div>
<script>
const date = new Date();
const digital_clock = document.querySelector('.clock')

const tick = () => {
const now = new Date();
const hour = now.getHours();
const minutes = now.getMinutes();
const seconds = now.getSeconds();
const createClockHtml = `
<span>${hour}</span> :
<span>${minutes}</span> :
<span>${seconds}</span>
`
digital_clock.innerHTML = createClockHtml;
}
setInterval(tick, 1000);

</script>
</body>

</html>