MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / updateClock

Function updateClock

assets/js/dateTimeWidget.js:8–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6};
7
8function updateClock() {
9 var now = new Date();
10 var sec = now.getSeconds(),
11 min = now.getMinutes(),
12 hou = now.getHours() % 12,
13 hou = hou ? hou : 12,
14 mo = now.getMonth(),
15 date = now.getDate(),
16 day = now.getDay(),
17 yr = now.getFullYear();
18 var months = [
19 "January",
20 "February",
21 "March",
22 "April",
23 "May",
24 "June",
25 "July",
26 "August",
27 "September",
28 "October",
29 "November",
30 "December",
31 ];
32 var days = [
33 "Sunday",
34 "Monday",
35 "Tuesday",
36 "Wednesday",
37 "Thursday",
38 "Friday",
39 "Saturday",
40 ];
41
42 var ampm = now.getHours() >= 12 ? " PM" : " AM";
43
44 corr = [days[day], months[mo], date, yr, hou.pad(2), min.pad(2), sec.pad(2)];
45
46 document.getElementById("day").innerHTML = `${days[day]},`;
47
48 document.getElementById("date").innerHTML = `${date} ${months[mo]} ${yr}`;
49
50 document.getElementById("time").innerHTML = `${hou.pad(2)} : ${min.pad(
51 2
52 )} : ${sec.pad(2)} ${ampm}`;
53}
54
55function initClock() {
56 updateClock();

Callers 1

initClockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected