-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path41_date.js
More file actions
38 lines (33 loc) · 688 Bytes
/
41_date.js
File metadata and controls
38 lines (33 loc) · 688 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
38
// Date
const months = [
'January',
'February',
'March',
'April',
'May ',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
];
const days = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu'];
const date = new Date();
console.log(date); //today : 2020-10-18T12:05:07.047Z
// getMonth
const month = date.getMonth();
console.log(months[month]);
// getDay
const day = date.getDay();
console.log(days[day]);
// getDate
console.log(date.getDate());
// getfullyears
console.log(date.getFullYear());
// example
const sentence = `${days[day]}, ${date.getDate()} ${
months[month]
} ${date.getFullYear()}`;
console.log(sentence);