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 8586097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:13:40+00:00 2026-06-11T22:13:40+00:00

EDIT: How could I pass a parameter when I call Clock.start() so I could

  • 0

EDIT: How could I pass a parameter when I call Clock.start() so I could change the value of totalSeconds?

I got a counter which value I concatenate with the ID of the timer display since there would be multiple lines of timers on the page but only one would be running for every user. I want to pass the value of the timer so i know which line the timer that I should fetch is on and then I’d convert that to seconds and then finally I could assign that value to totalSeconds. Then maybe I can get this working the way I pictured every thing.

WHAT I ALREADY HAVE RUNNING: I have a timer that doesn’t show that it’s counting up unless I refresh. When the page loads PHP queries mySQL and calculates the elapsed time with TIMEDIFF(now(), time_log), where time_log is when the timer started.

WHAT I’D LIKE TO ADD: What I want to do is use the js/jquery snippet below to get the my TIMEDIFF and then use that as totalSeconds, so totalSeconds wont reset and continue counting up from the TIMEDIFF value.

var Clock = 
{
    totalSeconds: 0,

    start: function () {
        var self = this;

        this.interval = setInterval(function () {
          self.totalSeconds += 1;

          var ctr;
          $(".icon-play").each(function(){
              if( $(this).parent().hasClass('hide') )
                  ctr = ($(this).attr('id')).split('_');
          });

          $("#hour_" + ctr[1]).text(pad(Math.floor(self.totalSeconds/3600)));
          $("#min_" + ctr[1]).text(pad( Math.floor((self.totalSeconds/60)%60) ));
          $("#sec_" + ctr[1]).text(pad(parseInt(self.totalSeconds%60)));
        }, 1000);
    },

    pause: function () {
      clearInterval(this.interval);
      delete this.interval;
    },

    resume: function () {
      if (this.interval) this.start();
    }
};

For this script, credits to Mr. Speransky Danil. how do I pause and resume a timer?

  • 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. Editorial Team
    Editorial Team
    2026-06-11T22:13:41+00:00Added an answer on June 11, 2026 at 10:13 pm

    Instead of recording total seconds, you should instead record the start time and calculate the number of seconds between now and when you started the timer.

    Additionally, you are already storing your start time in the database, so you could initialize from that when the page loads.

    If you simply count seconds, you will loose time between page refreshes.

    EDIT: You can init the Clock.totalSeconds in you HTML output generated by PHP. I understand you already have this clock JS working (with markup not posted above).

    <script type="text/javascript">
    var Clock = {}; // your code above
    Clock.totalSeconds = <?php echo (int)$seconds; ?>;
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know how I could edit mp3 files on the server
May i know how could i edit the style of description of the images
I need to ignore routes matching this schema /{controller}/edit/undefined {controller} - could be any
I usually edit RUBY files in VIM. I want the methods(def...end) to fold. Could
I am having issues, could you point me in the right direction? EDIT: This
If i have not strongly typed Partial and i want to pass parameter to
Class member functions in Python have to explicitly declare a self parameter which represents
Following this question - Pass Method as Parameter using C# and some of my
I've got an app which is using a WCF service. Now I'd like to
Here a field in my data records could pass the limit of 8000 chars

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.