-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaScript_eleventh.html
More file actions
34 lines (29 loc) · 953 Bytes
/
JavaScript_eleventh.html
File metadata and controls
34 lines (29 loc) · 953 Bytes
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
<!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>Date and Time in JavaScript</title>
</head>
<body>
<h1>Date and Time in JavaScript</h1>
<script>
let now = new Date();
console.log(now);
let nowYear = now.getFullYear();
console.log("The year is :", nowYear);
let nowHour = now.getHours(); // we have many more similar functions
console.log("The hour is :", nowHour);
console.log(Date.now()); // gives the number of milliseconds passed from the base time
let initial = Date.now();
let i;
for(i=0;i<100000;i+=1)
{
let j = 0;
}
let final = Date.now();
console.log("Time taken", final - initial);
</script>
</body>
</html>