diff --git a/index.html b/index.html index 191d3cc..c6cbb22 100644 --- a/index.html +++ b/index.html @@ -1,14 +1,39 @@ - - Clock Tower - - - - - -
- + + Clock Tower + + + + + + + + + + +
+
+ + + + + + + + + + + + + + diff --git a/index.js b/index.js index 877a3aa..68053b0 100644 --- a/index.js +++ b/index.js @@ -1 +1,34 @@ // Your code here + +function showTime(){ + + let date = new Date(); + let hour = date.getHours(); // 0 - 23 + let minute = date.getMinutes(); // 0 - 59 + let second = date.getSeconds(); // 0 - 59 + let meridian = "AM"; + + if(hour === 0){ + hour = 12; + } + + if(hour > 12){ + hour = hour - 12; + meridian = "PM"; + } + + hour = (hour < 10) ? "0" + hour : hour; + minute = (minute < 10) ? "0" + minute : minute; + second = (second < 10) ? "0" + second : second; + + let time = hour + ":" + minute + ":" + second + " " + meridian; + document.getElementById("clock").innerText = time; + document.getElementById("clock").textContent = time; + + setInterval(showTime, 1000); + +} + + + +showTime();