-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJS13.html
More file actions
63 lines (46 loc) · 1.63 KB
/
JS13.html
File metadata and controls
63 lines (46 loc) · 1.63 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
61
62
63
<!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 in JavaScript</title>
</head>
<body>
<div class="container">
Todays date and time is <span id="time"></span>
</div>
<script>
console.log('This is date and Time Tutorial')
let now = new Date()
console.log(now);
let dt = new Date(0)
console.log(dt);
// let newDate = new Date("2019-09-30");
// console.log(newDate);
// let newDate = new Date(year, month, date, hour, min, seconds, millsec);
let newDate = new Date(3020, 7, 10, 12, 56, 8, 33);
console.log(newDate);
let yr = newDate.getFullYear();
console.log('The year is ', yr);
let dt1 = newDate.getDate();
console.log('The date is ', dt1);
let mo = newDate.getMonth();
console.log('The year is ', mo);
let se = newDate.getSeconds();
console.log('The year is ', se);
// There are many more funstions to use in date and time
// and now how to change the date and time in the setted date and time
newDate.setDate(5);
console.log(newDate);
// Date.now();
// console.log()
setInterval(updateTime, 1000);
function updateTime(){
// time.innerHTML = new Date();
// This ill work like this and the dow one like this
let update = document.getElementById('time').innerHTML = new Date();
console.log(update)
}
</script>
</body>
</html>