Skip to content

Commit ca1f5b3

Browse files
committed
date
1 parent af1d4f8 commit ca1f5b3

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

41_date.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Date
2+
3+
const months = [
4+
'January',
5+
'February',
6+
'March',
7+
'April',
8+
'May ',
9+
'June',
10+
'July',
11+
'August',
12+
'September',
13+
'October',
14+
'November',
15+
'December',
16+
];
17+
18+
const days = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu'];
19+
20+
const date = new Date();
21+
console.log(date); //today : 2020-10-18T12:05:07.047Z
22+
// getMonth
23+
const month = date.getMonth();
24+
console.log(months[month]);
25+
// getDay
26+
const day = date.getDay();
27+
console.log(days[day]);
28+
29+
// getDate
30+
console.log(date.getDate());
31+
// getfullyears
32+
console.log(date.getFullYear());
33+
34+
// example
35+
const sentence = `${days[day]}, ${date.getDate()} ${
36+
months[month]
37+
} ${date.getFullYear()}`;
38+
console.log(sentence);

0 commit comments

Comments
 (0)