# How to insert date in a flash movie?

**URL:** <https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411>\
**Category:** Uncategorized\
**Created:** [April 5, 2002, 11:38pm UTC](https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411 "2002-04-05T23:38:31Z")\
**Posts on this page:** 12\
**Page:** 1

<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:** [April 5, 2002, 11:38pm UTC](https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411/1 "2002-04-05T23:38:31Z")

</div>

How to insert date in a flash movie ?

MMKt

---

<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:** [April 5, 2002, 11:44pm UTC](https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411/2 "2002-04-05T23:44:28Z")

</div>

[pub40.ezboard.com/fkirupa…D=16.topic](http://pub40.ezboard.com/fkirupafrm24.showMessage?topicID=16.topic)

if you have questions post.

---

<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:** [April 6, 2002, 2:58am UTC](https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411/3 "2002-04-06T02:58:21Z")

</div>

Yes I do have a question :

I have been at [pub40.ezboard.com/fkirupa...D=16.topic](http://pub40.ezboard.com/fkirupa...D=16.topic) as you suggested and got started by what it seemed the easiest one (let me first make an easier version to work before trying those others)

onClipEvent (enterFrame) {  
&nbsp &nbsp &nbsp &nbsp hours = getHours();  
&nbsp &nbsp &nbsp &nbsp minutes = getMinutes();  
&nbsp &nbsp &nbsp &nbsp seconds = getSeconds();  
&nbsp &nbsp &nbsp &nbsp time = hours+":"+minutes+":"+seconds;  
}

I have created a movie clip , and inside this a dynamic text box called time.  
I assigned your code to the movie clip.  
But it does not work.  
Could you please give me a help?  
Cheers  
MMKT

---

<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:** [April 6, 2002, 4:24am UTC](https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411/4 "2002-04-06T04:24:46Z")

</div>

you need to create the date object.

onClipEvent (enterFrame) {  
now = new Date()  
hours = now.getHours();  
minutes = now.getMinutes();  
seconds = now.getSeconds();  
time = hours+":"+minutes+":"+seconds;  
}

that code will work. The getHours() Minutes() etc are functions of the date object and therefore need that object to work. By saying now = new Date() you are create the needed date object.

anymore questions? post. Good luck

---

<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:** [April 6, 2002, 4:40am UTC](https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411/5 "2002-04-06T04:40:26Z")

</div>

///////////////////////////////\\\\\\\\\\\\\\\

Great Guy it does work !

Is there a way to show off am /pm ?

I suppose "get"command picks up the date from system clock , device that informs ante/post meridiem as well so  
that could be gotten likewise;  
It that too much complicated ?  
Thank you very much.  
Regards  
MMKT

/////////////////////////////\\\\\\\\\\\\\\

---

<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:** [April 6, 2002, 5:02am UTC](https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411/6 "2002-04-06T05:02:56Z")

</div>

Just after my last post some minutes ago , I remembered have read last week your post concerning a digital clock you were working on;

Do you intend to finish it ?

Cheers  
mmkt

---

<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:** [April 6, 2002, 5:07am UTC](https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411/7 "2002-04-06T05:07:50Z")

</div>

no there isn’t a fucntion to get am/pm but one can easily be made using if statements.

if (hours \>= 13){  
ampm = “pm”  
}else{  
ampm = “am”  
}  
}

put that into your code, and then your final code should look something like this::

onClipEvent (enterFrame) {  
now = new Date()  
hours = now.getHours();  
minutes = now.getMinutes();  
seconds = now.getSeconds();  
if (hours \>= 13){  
ampm = “pm”  
}else{  
ampm = “am”  
}  
}  
time = hours+":"+minutes+":"+seconds+" "+ampm  
}

that should work.

---

<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:** [April 6, 2002, 5:35am UTC](https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411/8 "2002-04-06T05:35:42Z")

</div>

Here I am once again;

Testing the clock I realized there is a bug, let´s suppose exactly now is 3:01 on system clock; the digital clock displays : 3:1:00 and not 3:01:00 ;

Bellow the error message I got by testing am/pm code:

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 12: Statement must appear within onClipEvent handler  
time = hours+":"+minutes+":"+seconds+" "+ampm

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 13: Unexpected ‘}’ encountered  
}

🙂 I think I ´ve had enough work for you today.

Really thank you a lot.  
MMKT

---

<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:** [April 6, 2002, 11:55am UTC](https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411/9 "2002-04-06T11:55:23Z")

</div>

You put 2 } in a row where there should be only one. And put the ; at the end of your last line. It doesn’t make any difference, but it’s better that way…  
pom 0]

---

<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:** [April 6, 2002, 4:12pm UTC](https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411/10 "2002-04-06T16:12:28Z")

</div>

as far as the 3:1:12 goes you can fix that by using another if statement.

if (length(minutes) == 1){  
minutes = “0”+minutes  
}  
if (length(seconds) == 1){  
seconds = “0”+seconds  
}

it is telling minutes to display a “0” in front of the digit if the length is 1. so that will display 01, 02, etc…just put that code into yours. And watch how many } you put at the bottom of the code. Its easy to get lost on how many of those you need.

Also, just so you know, Flash is going to display Military time. so 0-24 instead of 1-12, 1-12. This can be solved with another simple if statement. I’ll let you try to figure that one out on your own. If you don’t get it then post and I’ll give ya a hand.

---

<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:** [April 6, 2002, 11:46pm UTC](https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411/11 "2002-04-06T23:46:40Z")

</div>

Hello  
The corrected code is as bellow:

onClipEvent (enterFrame) {  
now = new Date();  
hours = now.getHours();  
minutes = now.getMinutes();

if (length(minutes) == 1){  
minutes = “0”+minutes  
}  
seconds = now.getSeconds();

if (length(seconds) == 1){  
seconds = “0”+seconds  
}  
time = hours+":"+minutes+":"+seconds;  
}

Concerning the change from military to 12 hours I will have  
to think a bit ; I am getting started and that´s not as easy for me as it is for you.  
Thank you.  
MMkt

---

<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:** [April 7, 2002, 12:11am UTC](https://forum.kirupa.com/t/how-to-insert-date-in-a-flash-movie/2411/12 "2002-04-07T00:11:49Z")

</div>

The code works great. I’ll give you a hint on the military time thing. An If statement will fix it. So what do you want to do? you want to make it so that when it is 13, it displays 1, up until when it says 24, it displays 12. Hope that helped. If not then let me know.
