-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path11. Q11.js
More file actions
30 lines (26 loc) · 1.08 KB
/
11. Q11.js
File metadata and controls
30 lines (26 loc) · 1.08 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
// 11. Use the Date object to do the following activities
// - What is the year today?
// - What is the month today as a number?
// - What is the date today?
// - What is the day today as a number?
// - What is the hours now?
// - What is the minutes now?
// - Find out the numbers of seconds elapsed from January 1, 1970 to now.
const date = new Date();
console.log(`What is the year today? - ${date.getFullYear()}`);
console.log(`What is the month today as a number? - ${date.getMonth()}`);
console.log(`What is the date today? - ${date.getDate()}`);
console.log(`What is the day today as a number? - ${date.getDay()}`);
console.log(`What is the hours now? - ${date.getHours()}`);
console.log(`What is the minutes now? - ${date.getMinutes()}`);
const newDate = new Date("1970-01-01T00:00:00Z");
// console.log(
// `Find out the numbers of seconds elapsed from January 1, 1970 to now. - ${
// date - newDate
// }`
// );
console.log(
`Find out the numbers of seconds elapsed from January 1, 1970 to now. - ${
date.getTime() - newDate.getTime() / 1000
}`
);