-
Notifications
You must be signed in to change notification settings - Fork 0
/
clock.js
37 lines (34 loc) · 999 Bytes
/
clock.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
startTime();
startdate();
//start the clock
function startTime() {
const today = new Date();
let h = today.getHours();
let m = today.getMinutes();
let s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('taskbar-clock-time').innerHTML = h + ":" + m + ":" + s;
setTimeout(startTime, 1000);
}
//checks the clock
function checkTime(i) {
if (i < 10) { i = "0" + i }; // add zero in front of numbers < 10
return i;
}
//start the date
function startdate() {
const todaydate = new Date();
let d = todaydate.getDate();
let m = todaydate.getMonth() + 1;
let y = todaydate.getFullYear();
d = checkDate(d);
m = checkDate(m);
document.getElementById('taskbar-clock-date').innerHTML = d + ":" + m + ":" + y;
setTimeout(startdate, 1000);
}
//checks the clock
function checkDate(i) {
if (i < 10) { i = "0" + i }; // add zero in front of numbers < 10
return i;
}