forked from kokonior/HTML-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShrijan26_clock.html
More file actions
58 lines (50 loc) · 1.65 KB
/
Shrijan26_clock.html
File metadata and controls
58 lines (50 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!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">
<title>Document</title>
</head>
<link href="https://fonts.googleapis.com/css2?family=Baloo+Bhai+2:wght@600&display=swap" rel="stylesheet">
<style>
body {
margin: 0px;
padding: 0px;
background: url("https://source.unsplash.com/1600x900/?nature,water");
}
#clock {
font-family: 'Baloo Bhai 2', cursive;
text-align: center;
background-color: #0000004f;
margin: 180px 320px;
color: #ffffff;
padding: 10px 10px;
/* border: 2px solid #ff4228; */
border-radius: 5px;
font-size: 50px;
}
</style>
<body onload="clocks(); setInterval('clocks()', 1000)">
<div id="clock">
</div>
</body>
<script>
function clocks() {
let time = new Date();
let hour = time.getHours();
let min = time.getMinutes();
let sec = time.getSeconds();
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
let date = time.toLocaleDateString(undefined, options);
hour = (hour < 10 ? "0" : "") + hour;
min = (min < 10 ? "0" : "") + min;
sec = (sec < 10 ? "0" : "") + sec;
let currenttime = (hour < 12) ? "AM" : "PM";
hour = (hour > 12) ? hour - 12 : hour
hour = (hour == 0) ? 12 : hour;
let strtime = hour + ":" + min + ":" + sec + " " + currenttime;
document.getElementById("clock").innerHTML = strtime + "<br> " + date;
}
</script>
</html>