# setInterval timer problems

**URL:** <https://forum.kirupa.com/t/setinterval-timer-problems/121219>\
**Category:** Uncategorized\
**Created:** [September 1, 2004, 12:54am UTC](https://forum.kirupa.com/t/setinterval-timer-problems/121219 "2004-09-01T00:54:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![serkios](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/serkios/32/608_2.png) [@serkios](https://forum.kirupa.com/u/serkios)\
**Post date:** [September 1, 2004, 12:54am UTC](https://forum.kirupa.com/t/setinterval-timer-problems/121219/1 "2004-09-01T00:54:06Z")

</div>

I’m trying to make a timer that when started, begins a movie and tracks its progression in seconds, minutes, and hours. I’ve been using SetInterval to count tenths of a second for accuracy. My problem is the timer doesn’t seem to be keeping time correctly. I let it run for 30 seconds against my windows clock and always comes like 5-6 seconds short. Anyone know whats up with this? Would getTimer() be more accurate??

```auto

   playInterval = setInterval(timer, 100);
   function timer () {
   	tenths++;
   	if (tenths>= 10) {
   		tenths= 0;
   		seconds++;
   	}
   	if (seconds >= 60) {
   		seconds = 0
   		minutes++;
   	}
   	if (minutes >= 60) {
   		minutes = 0;
   		hours++;
   	}	
   	// Format the digits properly
   	if (seconds <= 9) {
   		sec = "0" + seconds;
   	} else {
   		sec = seconds;
   	}
   	if (minutes <= 9) {
   		min = "0" + minutes;
   	} else {
   		min = minutes;
   	}
   	if (hours <= 9) {
   		hrs = "0" + hours;
   	} else {
   		hrs = hours;
   	}
   	timeToShow = hrs +":" + min + ":" + sec;
   	_root.timestamps_mc.video_mc.timer_txt.text = timeToShow;
   	updateAfterEvent();
   }
   

```
