javascript counter using seconds

Hello
  I want to create a counter that acts something like a clock.  The logic is this, a person dies from smoking every 8 seconds.  I want to know how many have died just this year - somewhere around 950,400 so far this year.  I would like to include the 'clock' on a website.

Thanks a ton!
JG
LVL 2
JGoyerAsked:
Who is Participating?
 
Pravin AsarPrincipal Systems EngineerCommented:
<html>
<head>
<title>Counter Document</title>
</head>

<body onLoad="MyCounter(); window.setInterval(MyCounter,8000);">
<script language="javascript">
function MyCounter () {
      var dt1 = new Date ('01/01/2006');
      dt1.setMinutes(0);
      dt1.setHours(0);
      dt1.setSeconds(0);
      var dt2 = new Date ();
      var diff = dt2 - dt1;
      //alert ('Number of people ' + (parseInt (diff)/(8*1000)).toFixed(0));
      var spanObj = document.getElementById('counter');
      if (spanObj) {
            spanObj.innerHTML = 'Number of people ' + (parseInt (diff)/(8*1000)).toFixed(0);
      }
}
</script>
<span id="counter">GO HERE </span>
</body>
</html>
0
 
bgloddeCommented:
0
 
Pravin AsarPrincipal Systems EngineerCommented:
JGoyer,

Just follow-up.. does my solution useful ??

_PA
0
 
JGoyerAuthor Commented:
awesome!  thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.