• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

150
Views
How to implement Synchronized countdown timer across different users

I would like to implement countdown timers in my project. However, I would like the countdown to be synchronized across all users. For example, if the countdown at user A is 03:05, the countdown at user B should be the same 03:05. I have been able to create a countdown timer, but I am not able to synchronize across all users. I would like to have an interval of 5 minutes, once the 5 minutes expires, the timer will restart at 5 min, 4:49, 4:48 etc to zero. This should be the same across all users or devices.

<script>
function startTimer(duration, display) {
    var timer = duration, minutes, seconds;
    setInterval(function () {
        minutes = parseInt(timer / 60, 10);
        seconds = parseInt(timer % 60, 10);

        minutes = minutes < 10 ? "0" + minutes : minutes;
        seconds = seconds < 10 ? "0" + seconds : seconds;

        display.textContent = minutes + ":" + seconds;

        if (--timer < 0) {
            timer = duration;
        }
    }, 1000);
}

window.onload = function () {
    var fiveMinutes = 60 * 1,
        display = document.querySelector('#demo');
    startTimer(fiveMinutes, display);
};

</script>
about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error