-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateTime.html
More file actions
145 lines (122 loc) · 3.88 KB
/
Copy pathDateTime.html
File metadata and controls
145 lines (122 loc) · 3.88 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Date & Time | JavaScript | Al- Arafat </title>
</head>
<body>
<H1> Assalamualaikum Or-Rohmatullah </H1>
<H2> Al - Arafat </H2>
</body>
<script src="DateTime.js"></script>
<script src="test-9.js"></script>
<script>
</script>
<script>
// Type-1:
/*
Date and Time in depth:
*/
/*
If you want to learn more about "Date":
1. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
2. https://tc39.es/proposal-temporal/docs/
*/
/*
let myDate = new Date()
console.log(myDate);
console.log(myDate.toString());
console.log(myDate.toISOString());
console.log(myDate.toDateString());
console.log(myDate.toLocaleDateString());
console.log(myDate.toLocaleString());
console.log(typeof myDate);
console.log(myDate.toJSON());
*/
/*
let myCreatedDate = new Date(2023,0,23)
console.log(myCreatedDate.toDateString());
*/
/*
let myCreatedDate1 = new Date(2023,0,23,5,3)
console.log(myCreatedDate1.toLocalString());
*/
/*
let myCreatedDate2 = new Date("2023-01-14")
console.log(myCreatedDate2.toLocalString());
*/
/*
let myCreatedDate3 = new Date("01-14-2023")
console.log(myCreatedDate3.toLocalString());
*/
/*
let myTimeStamp = Date.now()
console.log(myTimeStamp);
let myCreatedDate3 = new Date("01-14-2023")
console.log(myCreatedDate3.getTime());
// console.log(Date.now()/1000);
console.log(Math.floor(Date.now()/1000));
*/
/*
let newDate = Date()
// console.log(newDate);
console.log(newDate.getMonth());
console.log(newDate.getMonth()+1);
console.log(newDate.getDay());
// `${newDate.getDay()} and the time`
newDate.toLocaleString("default",{
weekday:"long" ,
// timezone:''
})
*/
/*
+++++++++++++++++++++++++++ X ++++++++++++++++++++++++++++++++++++++
*/
let myDate = new Date()
// console.log(myDate);
// console.log(myDate.toDateString());
// console.log(myDate.toExponential()); // TypeError: myDate.toExponential is not a function.
// console.log(myDate.toISOString());
// console.log(myDate.toLocaleDateString());
// console.log(myDate.toLocaleString());
// console.log(myDate.toJSON());
// console.log(myDate.toLocalString()); // TypeError: myDate.toLocalString is not a function
// console.log(myDate.toLocaleTimeString());
// console.log(myDate.toString());
// console.log(myDate.toTimeString());
// console.log(myDate.toUTCString());
// console.log(typeof myDate);
// ------------- X ------------------
let myCreatedDate = new Date(2023,0,23)
// console.log(myCreatedDate.toDateString());
let myCreatedDate1 = new Date(2023,0,23,5,3)
// console.log(myCreatedDate1.toLocalString()); // TypeError: myCreatedDate1.toLocalString is not a function
// console.log(myCreatedDate1.toLocaleString());
let myCreatedDate2 = new Date("2023-01-14")
// console.log(myCreatedDate2.toLocaleString());
let myCreatedDate3 = new Date("01-14-2023")
// console.log(myCreatedDate3.toLocaleString());
// ----------- X ----------
let myTimeStamp = Date.now()
// console.log(myTimeStamp);
let myCreatedDate4 = new Date("01-14-2023")
// console.log(myCreatedDate4.getTime());
// console.log(Date.now()/1000);
// console.log(Math.floor(Date.now()/1000));
// --------------- X -------------
let newDate = new Date()
// console.log(newDate);
// console.log(newDate.get);
// console.log(newDate.getMonth());
// console.log(newDate.getMonth()+1);
// console.log(newDate.getDay());
// console.log(newDate.getDay()+1);
// `${newDate.getDay()} and the time` // ReferenceError: Cannot access 'newDate' before initialization
newDate.toLocaleString("default",{
weekday:"long" ,
// timezone:''
})
// --------------- X -------------
</script>
</html>