# Function getTimer()

**URL:** <https://forum.kirupa.com/t/function-gettimer/163925>\
**Category:** Uncategorized\
**Created:** [September 27, 2005, 12:24pm UTC](https://forum.kirupa.com/t/function-gettimer/163925 "2005-09-27T12:24:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Dave](https://forum.kirupa.com/u/Dave)\
**Post date:** [September 27, 2005, 12:24pm UTC](https://forum.kirupa.com/t/function-gettimer/163925/1 "2005-09-27T12:24:10Z")

</div>

Hey GUys,

I dnt know how to do the actionscript tags so im gonna use the PHP ones!

```php

function startTimer() {
initial = getTimer()/1000;
}

```

If this function gets called, what exactly happens here? Does it reset the timer? Or just gets the time the swf has been playing?

Because when you use this mouse listener

```php

mouseListener = new Object();
mouseListener.onMouseDown = startTimer;

```

It actually resets the time everytime you mouseDown.

Does this make sense? Or do i need to write more?

This is the code all together. Thanks in advance 🙂

```php
 
mySeconds = 3;
mouseListener = new Object();
function startTimer() {
initial = getTimer()/1000;
}
function doyourstuff() {
_root.onEnterFrame = null;
_root.gotoAndStop(10);
}
_root.onEnterFrame = function() {
elapsedTime = Math.floor(getTimer()/1000-initial);
if (elapsedTime == mySeconds) {
doyourstuff();
}
trace(elapsedTime);
};
mouseListener.onMouseDown = startTimer;
Mouse.addListener(mouseListener);
startTimer();

```
