-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask4.html
More file actions
51 lines (46 loc) · 1.37 KB
/
task4.html
File metadata and controls
51 lines (46 loc) · 1.37 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Date and Time Display</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
}
button {
margin: 10px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
#resultDate,
#resultTime {
font-size: 20px;
}
</style>
</head>
<body>
<button onclick="showDate()">Show Date</button>
<br />
<button onclick="showTime()">Show Time</button>
<div id="resultDate"></div>
<div id="resultTime"></div>
<script>
function showDate() {
let currentDate = new Date();
let options = { year: "numeric", month: "long", day: "numeric" };
let formattedDate = currentDate.toLocaleDateString("en-US", options);
document.getElementById("resultDate").textContent = formattedDate;
document.getElementById("resultTime").textContent = "";
}
function showTime() {
let currentTime = new Date();
document.getElementById("resultTime").textContent = currentTime;
document.getElementById("resultDate").textContent = "";
}
</script>
</body>
</html>