-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
48 lines (34 loc) · 1.08 KB
/
script.js
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
39
40
41
42
43
44
45
46
47
48
/*Sunday, 12, January, 2020
Teresa Costa
I am a basic clock! :)
*/
function setDate(){
const now = new Date();
const padding = `0`;
//Full Date
//0 = January, 1=February, ...
let month = now.getMonth() + 1;
if (month < 10)
month = padding + month;
// getDate() = day of the month
let day = now.getDate();
if (day < 10)
day = padding + day;
document.getElementById("fullDate").innerHTML = `${now.getFullYear()}` + `-` + `${month}` + `-` + `${day}`;
//Full Time
let hours = now.getHours();
if (hours < 10)
hours = padding + hours;
let minutes = now.getMinutes();
if (minutes < 10)
minutes = padding + minutes;
let seconds = now.getSeconds();
if (seconds < 10)
seconds = padding + seconds;
document.getElementById("time").innerHTML = `${hours}` + `:` + `${minutes}` + `:` + `${seconds}`;
//Day of the Week
const wordDayOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
document.getElementById("dayOfWeek").innerHTML = `${wordDayOfWeek[now.getDay()]}`;
}
setInterval(setDate, 1000);
setDate();