-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path12. Q12.js
More file actions
37 lines (32 loc) · 851 Bytes
/
12. Q12.js
File metadata and controls
37 lines (32 loc) · 851 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
35
36
37
// 12. Create a human readable time format using the Date time object
// - YYYY-MM-DD HH:mm
// - DD-MM-YYYY HH:mm
// - DD/MM/YYYY HH:mm
const date = new Date();
const year = date.toLocaleString("default", { year: "numeric" });
const month = date.toLocaleString("default", { month: "2-digit" });
const day = date.toLocaleString("default", { day: "2-digit" });
// YYYY-MM-DD HH:mm
console.log(
`${year}-${month}-${day} ${date.toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit",
})}`
);
// DD-MM-YYYY HH:mm
console.log(
`${day}-${month}-${year} ${date.toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit",
})}`
);
// DD/MM/YYYY HH:mm
console.log(
date.toLocaleString("default", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
})
);