JavaScript Clock/Timer for website

I am looking for a JavaScript Clock/Timer for our webpage. I want something that can keep a real-time connection to the current date and trigger things to happen based on the time. Does anybody know of such an addon, library? Thanks

setInterval.

Thanks for reply, this would handle the timer part.

I am sorry I really want a date and time on a webpage. I also want a running timer that relates to that current time. I thought there must be something that does this well for “time” like how I use VideoJS for video. Is there? If not I will look at the idea of building it all myself. Is there no library that handles time in JavaScript robustly (aren’t I spoiled :rofl:)?

This Codepen might get you started:

That’s a really long way to write
setInterval(document.getElementById("theDate").innerHTML = new Date().toLocaleDateString('en-gb', { weekday:"long", year:"numeric", month:"short", day:"numeric", hour:"numeric", minute:"numeric", second:"numeric"}),1000); :wink:

2 Likes

Ah, but it was more fun! :biggrin:

3 Likes

Following Steps may be helpful to you:

-Set the end date for the timer
-Make the timer function update every second
-Calculate the remaining time in days, hours, minutes, and seconds
​-Display the output to users
-Display a message when the timer is over