diff --git a/public/js/datetime.js b/public/js/datetime.js new file mode 100644 index 0000000..19b7189 --- /dev/null +++ b/public/js/datetime.js @@ -0,0 +1,28 @@ +function updateDateTime() { + const el = document.getElementById("datetime"); + if (!el) return; + + const now = new Date(); + + const weekdays = [ + "Sonntag", + "Montag", + "Dienstag", + "Mittwoch", + "Donnerstag", + "Freitag", + "Samstag", + ]; + + const dayName = weekdays[now.getDay()]; + const day = String(now.getDate()).padStart(2, "0"); + const month = String(now.getMonth() + 1).padStart(2, "0"); + const year = now.getFullYear(); + const hours = String(now.getHours()).padStart(2, "0"); + const minutes = String(now.getMinutes()).padStart(2, "0"); + + el.textContent = `${dayName} ${day}.${month}.${year} ${hours}:${minutes}`; +} + +updateDateTime(); +setInterval(updateDateTime, 1000); diff --git a/views/dashboard.ejs b/views/dashboard.ejs index 5d06917..c3c2c9e 100644 --- a/views/dashboard.ejs +++ b/views/dashboard.ejs @@ -7,6 +7,7 @@ +