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

  • SEARCH
  • Home
  • 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 8190003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:28:28+00:00 2026-06-07T03:28:28+00:00

I want to show the time which I have in my php variable with

  • 0

I want to show the time which I have in my php variable with the help of Javascript

I am coding an online exam module, where I want to display the total elapsed time

say for example

$time_elapsed // contains the time taken till now from the start of the exam
And if I got a div say,

<div id="time"></div> 

how can I show the dynamic running time with starting from $time_elapsed after load the window for each question

Please if you guys have an answer for this..

Thanks

  • 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-07T03:28:31+00:00Added an answer on June 7, 2026 at 3:28 am

    hi you can use the following code for the purpose

    the javascript will be:

    var Timer;
    var TotalSeconds,TotalMins, secs;
    var elapsedtime ;
    
    function CreateTimer(TimerID, Time) {
            Timer = document.getElementById(TimerID);
            TotalSeconds = Time;
            elapsedtime = 0
            time = Time
            secs = TotalSeconds%60;
            TotalMins = Math.floor(TotalSeconds/60)
            UpdateTimer()
            window.setTimeout("Tick()", 1000);
    }
    
    function Tick() {
    if(TotalSeconds-elapsedtime>0)
    {
        elapsedtime += 1;
        secs = (elapsedtime%60)-60;
        TotalMins = Math.floor(elapsedtime/60)
        UpdateTimer()
        window.setTimeout("Tick()", 1000);
    }
    else
    alert("time up")
    }
    
    function UpdateTimer() {
            Timer.innerHTML = TotalMins + ":" + secs;
    }
    

    nw create a html div where you want to show the running time.

    Html:

    <div id='timer' />
    <script type="text/javascript">window.onload = CreateTimer("timer", 5);</script>
    

    give parameter the time limit. it will alert after time finishes.

    and to get time after refresh of the page use html5’s sessionStorage

    visit Html5 Storage Doc to get more details. using this you can store intermediate values temporaryly/permanently locally and then access your values
    for storing values for a session

    sessionStorage.getItem('label')
    sessionStorage.setItem('value', 'label')
    

    or store values permanently using

    localStorage.getItem('label')
    localStorage.setItem('value', 'label')
    

    So you can store (temporarily) form data between multiple pages using html5 storage objects

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 pages that I want to show as instructions the first time
We all have come across web pages which take some time to show the
I have a table Which I want show recursively like below picture I am
Background: I want to show the time and date uptill only 1 week. After
I want to show array objects at the same time in different 10 labels.
If i want to show userLocation on the map, and at the same time
I want to be able to show the elapsed time in a textview or
I'm using Drupal 7 and Views module in my site. And want show number
I have list of products which have EditText in TableLayout . I want Keyboard
I'm an beginner in php/msql, and need help to solve this problem: I have

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.