show time spent on page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sanjay123456
    New Member
    • Sep 2006
    • 125

    show time spent on page

    i would like to show a clock on the page that would be calll again and again its show a clock and should be show total elapsed time how can i do it

    [PHP]
    <?php
    $t=time();
    echo($t . "<br />");
    ?>
    [/PHP]

    i found only this ?
  • michaelb
    Recognized Expert Contributor
    • Nov 2006
    • 534

    #2
    I guess what you need is to have a clock on your page which would keep continuously updating the time.

    If this is the case you may need to look at using Javascript + dynamic html.
    (PHP is a server side code, so once page is rendered there's not much you can do)

    Look at the Javascript setTimeout() function.
    Using it, you can call your own function every N seconds. Your function may do something like this:
    Code:
    document.myForm.mySpan.innerHTML = <current_time>;
    For getting current date/time look at the Javascript Date object and its functions.
    If you need more help with this you better off posting your question to the Javascript Forum.

    Comment

    • michaelb
      Recognized Expert Contributor
      • Nov 2006
      • 534

      #3
      Originally posted by michaelb
      Look at the Javascript setTimeout() function.
      Sorry, in this case setInterval() would serve you better, it won't require a reset.

      Comment

      Working...