# Time elapsed

**URL:** <https://forum.kirupa.com/t/time-elapsed/34255>\
**Category:** flash\
**Created:** [October 30, 2003, 12:18pm UTC](https://forum.kirupa.com/t/time-elapsed/34255 "2003-10-30T12:18:38Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ubik](https://avatars.discourse-cdn.com/v4/letter/u/b38774/32.png) [@Ubik](https://forum.kirupa.com/u/Ubik)\
**Post date:** [October 30, 2003, 12:18pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/1 "2003-10-30T12:18:38Z")

</div>

Does anyone know a script that can display the time elapsed on a site like this [http://www.kaos-films.com/french/index2.html](http://www.kaos-films.com/french/index2.html) , i took a look at the countdown timer tutorial but it’s not what i’m looking for …

Thanks !

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 30, 2003, 5:03pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/2 "2003-10-30T17:03:18Z")

</div>

couldnt you do it with a function which increments a value, beginning when the site first loads which you could then translate to a 24 clock type interface?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 30, 2003, 5:20pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/3 "2003-10-30T17:20:35Z")

</div>

uuhh …  
I’m just beginning with as… i totally don’t know how to do this …

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 30, 2003, 5:40pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/4 "2003-10-30T17:40:39Z")

</div>

Create a textfield with an instance name of timerText. Now place this code on the timeline:[AS]this.onEnterFrame = function() {  
myTime = getTimer()/1000;  
hours = Math.floor(myTime/3600);  
minutes = Math.floor((myTime/3600-hours)\*60);  
seconds = Math.floor(((myTime/3600-hours)_60-minutes)60);  
mili = Math.floor((myTime-(seconds+(minutes60)+(hours_3600)))\*100);  
myhours = (hours\<10) ? “0”+hours : hours;  
myseconds = (seconds\<10) ? “0”+seconds : seconds;  
myminutes = (minutes\<10) ? “0”+minutes : minutes;  
mymili = (mili\<10) ? “0”+mili : mili;  
timerText = myhours+":"+myminutes+":"+myseconds+":"+mymili;  
};  
[/AS]That should do the trick.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 30, 2003, 5:50pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/5 "2003-10-30T17:50:00Z")

</div>

Hehe, that code looks semi-familiar 😉 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 30, 2003, 5:55pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/6 "2003-10-30T17:55:33Z")

</div>

Have you posted that code here lost? 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 30, 2003, 5:57pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/7 "2003-10-30T17:57:27Z")

</div>

I posted similar code during the footer content stuff… here is the part of the code that used it…

[AS]TextField.prototype.updateTimeValue = function() {  
myTime = new Date();  
h = myTime.getHours();  
m = myTime.getMinutes();  
s = myTime.getSeconds();  
ms = myTime.getMilliseconds().toString();  
h == 12 || h == 0 ? hours=12 : (h%12)\<10 ? hours=“0”+(h%12) : hours=h%12;  
m\<10 ? minutes=“0”+m : minutes=m;  
s\<10 ? seconds=“0”+s : seconds=s;  
ms.length\<2 ? milliSeconds=“00”+ms : ms.length\<3 ? milliSeconds=“0”+ms : milliSeconds=ms;  
h\<12 ? amPM=“AM” : amPM=“PM”;  
this.text = hours+" . “+minutes+” . “+seconds+” . “+milliSeconds+” . "+amPM;  
};[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 30, 2003, 6:00pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/8 "2003-10-30T18:00:35Z")

</div>

Ahh… it have something in commom but not identical 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 30, 2003, 6:05pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/9 "2003-10-30T18:05:21Z")

</div>

That’s why I said semi-familiar 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 30, 2003, 6:16pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/10 "2003-10-30T18:16:37Z")

</div>

Ok, a little off topic, but looking at your code here lostinbeta…  
[AS]  
h == 12 || h == 0 ? hours=12 : (h%12)\<10 ? hours=“0”+(h%12) : hours=h%12;  
[/AS]  
is that a “nested” Tertiary operation? I didn’t know you could do that, maybe it should be added to the Tertiary Operator tutorial. and since I’m asking about it I might as well throw this one out as well - the Tertiary operator can also do this.

```auto

a=2;
b=5;
a > b ? c=2:d=3, e=4, f=5;
trace(d); // 3
trace(e); // 4
trace(f); // 5

```

in the tutorial it doesn’t really show that you can give multiple statements… it might be useful. I don’t know why I thought I would mention updating the tutorial in this thread, and to someone who didn’t even write it… but, I’m going to shut up now.:x

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 30, 2003, 6:19pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/11 "2003-10-30T18:19:51Z")

</div>

Yes it is a nested tertiary operator

? = if

: = else

So it is basically an if/else if statement [AS]  
if (h==12 || h==0) {  
hours = 12;  
} else if ((h%12)\<10){  
hours = “0”+(h%12);  
} else {  
hours = h%12;  
}  
[/AS]

Oh yeah, and for multiple statements you need parenthesis… [AS]a = 2;  
b = 5;  
a\>b ? c=2 : (d=3, e=4, f=5);[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 31, 2003, 10:03am UTC](https://forum.kirupa.com/t/time-elapsed/34255/12 "2003-10-31T10:03:39Z")

</div>

Hey !  
Thank you guys, i just came back and see all the reply !  
I’m going to see how it works !🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 31, 2003, 11:36am UTC](https://forum.kirupa.com/t/time-elapsed/34255/13 "2003-10-31T11:36:03Z")

</div>

i’ve just tried your code your code Claudio and yours too lostinpanda but … i don’t see anything on the screen,  
maybe i’m too stupid to use it :beam:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 31, 2003, 2:01pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/14 "2003-10-31T14:01:44Z")

</div>

will try knocking something up for you when i get the chance man, till then have you put Dynamic text fields on the stage (as you will neeed em for the above)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 31, 2003, 2:24pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/15 "2003-10-31T14:24:03Z")

</div>

yes, I’ve put a Dynamic text fields on the stage but …  
Thanks for your help ave!  
Ubik

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 31, 2003, 4:10pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/16 "2003-10-31T16:10:23Z")

</div>

Sorry, replace the last line for:

```auto
timerText.text = myhours+":"+myminutes+":"+myseconds+":"+mymili;

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 31, 2003, 5:15pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/17 "2003-10-31T17:15:32Z")

</div>

yeah !  
Excellent ! thank you claudio !

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 31, 2003, 7:08pm UTC](https://forum.kirupa.com/t/time-elapsed/34255/18 "2003-10-31T19:08:29Z")

</div>

Welcome 😉
