-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDates.html
More file actions
60 lines (49 loc) · 1.99 KB
/
Dates.html
File metadata and controls
60 lines (49 loc) · 1.99 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
59
60
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Getting Date</title>
<script>
function print(){
// Current date and time
let currentDate = new Date();
let year = currentDate.getFullYear();
let month = currentDate.getMonth(); // 0-based (0 = January)
let day = currentDate.getDate();
let hours = currentDate.getHours();
let minutes = currentDate.getMinutes();
let seconds = currentDate.getSeconds();
let milliseconds = currentDate.getMilliseconds();
document.getElementById("year").innerHTML = year;
document.getElementById("month").innerHTML = month;
document.getElementById("day").innerHTML = day;
document.getElementById("hours").innerHTML = hours;
document.getElementById("minutes").innerHTML = minutes;
document.getElementById("Seconds").innerHTML = seconds;
document.getElementById("milliseconds").innerHTML = milliseconds;
document.getElementById("currentDate").innerHTML = currentDate;
}
</script>
</head>
<body>
<h1>Getting Date</h1>
<ol>
<li>year : <span id="year"></span></li>
<li>month : <span id="month"></span></li>
<li>day : <span id="day"></span></li>
<li>hours : <span id="hours"></span></li>
<li>minutes : <span id="minutes"></span></li>
<li>Seconds : <span id="Seconds"></span></li>
<li>milliseconds : <span id="milliseconds"></span></li>
<li>currentDate : <span id="currentDate"></span></li>
</ul>
<button onclick="print()">Click to print Date </button>
</body>
</html>
<style>
span{
color: brown;
font-weight: bold;
}
</style>