[MX] getDate and switch problem

I have this huge thing of actionscript (See below) which I wrote my self and unsurprisingly it has some problems, it is meant to get the day, date and month values and switch them to get the text equivilent of that integer. Well not exactly it gets the day right at least but then it gave me the 3th (Try to pronounce that) of " " month. I am stuck? Here is the AS

[AS]

setInterval(dateSet,2500000000000000000000000000000);
function dateSet(){
var day = new Date().getDay();
var txtDay;
switch(day){
case 0:
txtDay = “Sunday”;
break;
case 1:
txtDay = “Monday”;
break;
case 2:
txtDay = “Tuesday”;
break;
case 3:
txtDay = “Wednesday”;
break;
case 4:
txtDay = “Thursday”;
break;
case 5:
txtDay = “Friday”;
break;
case 6:
txtDay = “Saturday”;
break;
default:
txtDay = “Error”;
break;
}
var date = new Date().getDate();
var txtDate;
switch (date){
case 1:
txtDate = “1st”;
break;
case 2:
txtDate = “2nd”;
break;
case 3:
txtDate = “3rd”;
break;
case 21:
txtDate = “21st”;
break;
case 22:
txtDate = “22nd”;
break;
case 23:
txtDate = “23rd”;
break;
case 31:
txtDate = “31st”;
break;
default:
txtDate = day + “th”;
break;
}
var txtMonth = new Date().getMonth();
var txtMonth
switch (month){
case 0:
txtMonth = “January”;
break;
case 1:
txtMonth = “February”;
break;
case 2:
txtMonth = “March”;
break;
case 3:
txtMonth = “April”;
break;
case 4:
txtMonth = “May”;
break;
case 5:
txtMonth = “June”;
break;
case 6:
txtMonth = “July”;
break;
case 7:
txtMonth = “August”;
break;
case 8:
txtMonth = “September”;
break;
case 9:
txtMonth = “October”;
break;
case 10:
txtMonth = “November”;
break;
case 11:
txtMonth = “December”;
break;
}
_root.txtOveralDate = txtDay + ", " + txtDate + ", " + txtMonth;
}

[/AS]

This should help you:[AS]var weekArray = [“Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”];
var monthsArray = [“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”];
var myDate = new Date();
var day = myDate.getDay();
var month = myDate.getMonth();
var monthday = myDate.getDate().toString();
var which = monthday.charAt(monthday.length-1);
if (which == 1) {
monthday += “st”;
} else if (which == 2) {
monthday += “nd”;
} else if (which == 3) {
monthday += “rd”;
} else {
monthday += “th”;
}
var complete_date = weekArray[day]+", “+monthday+”, "+monthsArray[month];
//complete_date is the variable associated to your textfield[/AS]

Hey thanx Claudio I did think to use an array but never thought how I could do it, it has given me an insight on how to work with retrieving data from them using [] to evaluate data and them pick the right one. Anyway thanks again!

welcome :wink:
i thought that way would be easier for me. i hate case/switch :stuck_out_tongue:

Yeh huge size difference

Yep :sure: