Skip to content

Commit d63e563

Browse files
authored
Merge pull request #13 from jorgemonte/add-digital-clock
Add Javascript Digital-Clock
2 parents 9856aad + 7762794 commit d63e563

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

digital-clock/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Javascript Digital Clock</title>
6+
<link rel="stylesheet" href="style.css">
7+
</head>
8+
<body>
9+
<div class="container">
10+
jjj
11+
</div>
12+
<script src="script.js"></script>
13+
</body>
14+
</html>

digital-clock/script.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(function() {
2+
function addZeroBefore(v) {
3+
return +v < 10 ? "0" + +v : v;
4+
}
5+
6+
function showTime() {
7+
8+
var today = new Date();
9+
var textTime = addZeroBefore(today.getHours()) + " : " + addZeroBefore(today.getMinutes()) + " : " + addZeroBefore(today.getSeconds());
10+
11+
document.getElementById("time").innerHTML = textTime;
12+
13+
setTimeout(function() {
14+
showTime()
15+
}, 1000);
16+
}
17+
18+
showTime();
19+
})();

digital-clock/style.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
*{
2+
padding:0;
3+
margin:0;
4+
}
5+
6+
7+
.container{
8+
background-color:#3030bb;
9+
height:100vh;
10+
padding:30px 40px;
11+
display:flex;
12+
font-size:10em;
13+
justify-content: center;
14+
align-items: center;
15+
color:whitesmoke;
16+
font-family: courier;
17+
}
18+

0 commit comments

Comments
 (0)