Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Posts
    225
    Thanks
    6
    Thanked 3 Times in 3 Posts

    Timer: User at page

    I'm trying to make a timer that displays how long a user has stayed at the page. I wish to display the time in the format hh:mm:ss.

    PHP Code:
    function timeAtPage() {
    if (
    started == 0) {
    startingTime = new Date();
    startingHour startingTime.getHours();
    startingMin startingTime.getMinutes();
    startingSec startingTime.getSeconds();
    started 1;
    }
    currentTime = new Date();
    currentHour currentTime.getHours();
    currentMin currentTime.getMinutes();
    currentSec currentTime.getSeconds();
    timeHour currentHour startingHour;
    timeMin currentMin startingMin;
    timeSec currentSec startingSec;
    document.clockForm.timeatpage.value timeHour+":"+timeMin+":"+timeSec;
    clockTimer setTimeout('timeAtPage()',1000);

    This does not change the value of the text box at all. Is this the best way of displaying the time, and what is wrong with my code?

    Any help would be greatly appreciated.

  • #2
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    877
    Thanks
    53
    Thanked 6 Times in 5 Posts
    Don't know why your code doesn't work, but I use this code:

    (if yours worked I would change to yours - it's much shorter!)

    http://www.jdstiles.com/java/timer1.html


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •