Time Counter Scripts

Time Counter 2 (click here to see it on my blog)

<!DOCTYPE HTML>

<html>

<head>

<title>Time Counter</title>

</head>

<body bgcolor=B0E0E6 onload= "timeCount()">

<center>

<script type="text/javascript">

/* Time Counter 2.

The main purpose of this application is to show a visitor how much time he/she spends on the web page.

Author : Michael Langerman. 2012

www.fewdoit.com

email : fewdoit@gmail.com

Many thanks to www.javascript.info www.w3schools.com www.javascriptsource.com and all people supporting free open

internet comunity with free tutorials and references.

Thanks everone for sharing your knowledge and expertise.

This program is free software : you can redistribute it and / or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

See < http : // www.gnu.org / licenses / > .

*/

var seconds = 0;

var minutes = 0;

var hours = 0;

var intervalSeconds;

var timerIsOn = 0;

function timeCount()

{

seconds = seconds + 1;

intervalSeconds = setTimeout("timeCount()", 1000);

document.getElementById("time").value = hours + ":" + minutes + ":" + seconds;

if (seconds >= 60)

{

minutes = Math.floor (seconds / 60) + minutes;

seconds %= 60;

}

if (minutes >= 60)

{

hours = Math.floor (minutes / 60) + hours;

minutes %= 60;

}

}

function playTimer()//activates when user clicks on the "Play" button.

{

if ( ! timerIsOn)//check if the user clicks one time on the "Play" button-to avoid many timers at the same time.

{

timerIsOn = 1;

timeCount();

}

}

function stopTimer()//activates when user clicks on the "Pause" button.

{

clearTimeout(intervalSeconds);

timerIsOn = 0;

}

</script>

So far you spent <output type="text" size=6 id="time"></output> on this page.<br>

<input type="button" value="Pause" onclick="stopTimer()">

<input type="button" value="Play" onclick="playTimer()"><br>

<font> <a href="http://www.fewdoit.com">www.fewdoit.com</a><br>

for you</font>

</center>

</body>

</html>

Time Counter (click here to see it on my blog)

<!DOCTYPE HTML>

<html>

<head>

<title>Time Counter</title>

</head>

<body bgcolor=B0E0E6 onload= "timeCount()">

<center>

<script type="text/javascript">

/* Time Counter 1.

The main purpose of this application is to convert running number of seconds to more user friendly display format in: hours, minutes and seconds.

Author : Michael Langerman. 2012

www.fewdoit.com

email : fewdoit@gmail.com

Many thanks to www.javascript.info www.w3schools.com www.javascriptsource.com and all people supporting free open

internet comunity with free tutorials and references.

Thanks everone for sharing your knowledge and expertise.

This program is free software : you can redistribute it and / or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

See < http : // www.gnu.org / licenses / > .

*/

var seconds = 0;

var minutes = 0;

var hours = 0;

var intervalSeconds;

function timeCount()

{

seconds = seconds + 1;

intervalSeconds = setTimeout("timeCount()", 1000);

document.getElementById("time").value = hours + ":" + minutes + ":" + seconds;

if (seconds >= 60)

{

minutes = Math.floor (seconds / 60) + minutes;

seconds %= 60;

}

if (minutes >= 60)

{

hours = Math.floor (minutes / 60) + hours;

minutes %= 60;

}

}

</script>

So far you spent <output type="text" size=6 id="time"></output> on this page.<br>

<font> <a href="http://www.fewdoit.com">www.fewdoit.com</a><br>

for you</font>

</center>

</body>

</html>