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


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:


Ah, but it was more fun! :biggrin:


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


This is helpful. Thank You

I will need this when I write my functions to set a timer based on the current time. I don’t know if I will need PHP and MySQL for storing the time to keep track of where it is at. Or does JavaScript give some mechanism to do so? Thanks

Depends on what you’re storing it for, or more precisely, who needs to access the information.

If i’m storing “Hey everybody, we’ve got a meeting next tuesday”, I need to store it on a server because other people need to access that data.
If i’m storing “I’ve got a 3:30 on thursday” and I want to do it lightweight, I can store that information locally in the browser’s storage, and recall it when the browser opens the page.
However, if I want to be able to have a user’s reminders transfer between devices, I’ll need to store it on a server again.

In general, if you only care about this user on this device, you can store the information locally using Javascript. Otherwise, you’re going to need a server-side solution.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.