Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 87639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:26:04+00:00 2026-05-10T22:26:04+00:00

I have from the backend a time on the format 00:12:54 and I display

  • 0

I have from the backend a time on the format 00:12:54 and I display it to the screen. But, I would like to have this time to continue to go down. I have though to create a variable in javascript that will old the time and with setTimeout to loop to display with document.getElementById the new value. I think it can be problematic if I have many time to go down in same time. I might require an array?

How would you do that? If I have no other suggestion, I will try my way, but I am curious to know if it does have a more secure way to do it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:26:04+00:00Added an answer on May 10, 2026 at 10:26 pm

    General algorithm:

    1. Read time from server.
    2. Read the current time.
    3. Call a function.
    4. In your function, read the current time, get the delta from the initial time you read in step 2.
    5. Subtract the delta from the initial time you read from the server in step 1 and display the remainder.
    6. The function should call window.setTimeout to call itself in 1000ms (or adjust according to time elapsed within the function), if you want to continue counting down.

    Here’s a rough cut:

    window.onload = function () {     var countdown_start_in_ms = 6000; // from server      function tick() {         var now = new Date().getTime();         var disp = start - now;          if (disp < 0) {             disp = 0;         }          var el = document.getElementById('countdown');          el.innerHTML =             // quick hack to format time             /(\d\d:\d\d:\d\d) ...$/.exec(new Date(disp).toUTCString())[1];          if (disp > 1000) {             var elapsed = new Date().getTime() - now;             window.setTimeout(tick, 1000 - elapsed);         } else {             // stop countdown and set color to light grey             el.style.color = '#ccc';         }     }      var start = new Date().getTime() + countdown_start_in_ms;     tick(); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 58k
  • Answers 58k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer It is read from machine.config, you can either make sure… May 11, 2026 at 8:50 am
  • added an answer As far as I know there isn't an 'all' switch… May 11, 2026 at 8:50 am
  • added an answer For general application configuration that doesn't need to be stored… May 11, 2026 at 8:49 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.