Skip to content

Commit 38d1f19

Browse files
committed
#14 - javascript
1 parent 527ad3a commit 38d1f19

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
let birth_day = new Date(1991,8,11,15,0,0,0);
3+
let now = new Date();
4+
console.log(birth_day);
5+
console.log(now);
6+
7+
let dif = now.getFullYear() - birth_day.getFullYear();
8+
console.log(`Diference in year is ${dif}`);
9+
10+
/*Extra*/
11+
12+
//Day of the week
13+
const formatter_day = new Intl.DateTimeFormat('en', { weekday: 'long' });
14+
day_name = formatter_day.format(birth_day);
15+
console.log(`Day of the week for birth date was: ${day_name}`);
16+
17+
//Name of the month
18+
const formatter = new Intl.DateTimeFormat('en', { month: 'long' });
19+
month_name = formatter.format(birth_day);
20+
console.log(`Month for birth date was ${month_name}`);
21+
22+
//Format date Spanish format
23+
console.log('Formatting date in Spanish version: ',new Intl.DateTimeFormat('es').format(birth_day));
24+
25+
//Format date USA format
26+
console.log('Formatting date in USA version: ',new Intl.DateTimeFormat('en-US').format(birth_day));
27+
28+
// Format date HH:MM:SS
29+
console.log(`Formating HH:MM:SS: ${birth_day.getHours()}:${birth_day.getMinutes()}:${birth_day.getSeconds()}`)

0 commit comments

Comments
 (0)