-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime.html
35 lines (30 loc) · 1.02 KB
/
time.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>colck</title>
<link rel="stylesheet" href="./style.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
</head>
<body>
<!-- d-flex justify-content-center -->
<div class="d-flex justify-content-center align-items-center" vh="100">
<h1 id="output" class="fw-bold head-sty">HH:MM:SS AM</h1>
</div>
</body>
<script>
const getDateTime=()=>{
const localTime=new Date()
// console.log(localTime);
const hours=localTime.getHours()
const minutes=localTime.getMinutes()
const seconds=localTime.getSeconds()
output.innerHTML=`${hours}:${minutes}:${seconds} ${hours>12?'PM':'AM'}`
setTimeout(() => {
getDateTime()
}, 1000);
}
getDateTime()
</script>
</html>