# (FMX2004)Why?Why?Why?

**URL:** https://forum.kirupa.com/t/fmx2004-why-why-why/184684
**Category:** flash
**Created:** [April 6, 2006, 8:10pm UTC](https://forum.kirupa.com/t/fmx2004-why-why-why/184684 "2006-04-06T20:10:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![stinkyme](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@stinkyme](https://forum.kirupa.com/u/stinkyme)
#### Post date: [April 6, 2006, 8:10pm UTC](https://forum.kirupa.com/t/fmx2004-why-why-why/184684/1 "2006-04-06T20:10:52Z")

</div>

I’m teaching myself this so I’m just an actionscript baby. Would anyone mind taking a peek at this code and telling me why I just see this output? Thank you…thank you so much!

**OUTPUT:**  
12:undefinedAM  
It is now 12:undefinedAM onundefined,undefined undefined, undefined.

**CODE:**  
function myTime(){  
var currentTime;  
if(my\_date.getHours() \> 12){  
currentTime = my\_date.getHours() - 12 + “:” + my\_date.getMinutes() + “PM”;  
}else if((my\_date.getHours() \< 12) && (my\_date.getHours() != 0)){  
currentTime = my\_date.getHours() + “:” + my\_date.getMinutes() + “AM”;  
}else if(my\_date.getHours() == 12){  
currentTime = my\_date.getHours() + “:” + my\_date.getMinutes() + “PM”;  
}else{  
currentTime = “12:” + my\_date.getMinutes() + “AM”;  
}  
return currentTime;  
}  
trace(myTime());

function weekday() {  
myDay = Array(“Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”);  
return myDay[my\_date.getDay()];  
}  
function myMonth() {  
var month = new Array(“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”);  
return month[my\_date.getMonth()];  
}  
trace("It is now “+ myTime() + " on”+ weekday() + “,” + myMonth() + " " + my\_date.getDate() + ", " +my\_date.getFullYear() + “.”);

---

<div class="post-metadata">

### Author: ![NinoScript](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ninoscript/32/1484_2.png) [@NinoScript](https://forum.kirupa.com/u/NinoScript)
#### Post date: [April 6, 2006, 9:22pm UTC](https://forum.kirupa.com/t/fmx2004-why-why-why/184684/2 "2006-04-06T21:22:20Z")

</div>

you’re using “my\_date”'s methods, but u havnt defined it…

just add this at the start of your code:

```auto
var my_date = new Date();

```

[size=1]btw, use[noparse]

```auto

```

[/noparse] tags[/size]
