for some reason, right now my date displays as June, 5th.
i know it has soemthign to do with the array i made, just can’t figure out why this is happening.
[AS]
onClipEvent(load){
mon = [“Jan,”,“Feb”,“Mar”,“Apr”,“May”,“Jun”,“Jul”,“Aug”,“Sep”,“Oct”,“Nov”,“Dec”];
weekdays = [“Subnday”,“Monday”,“Tuesday”,“Wednesday”,“Thursday”,“Friday”,“Saturday”,“Sunday”];
daynum = [“1st”,“2nd”,“3rd”,“4th”,“5th”,“6th”,“7th”,“8th”,“9th”,“10th”,“11th”,“12th”,“13th”,“14th”,“15th”,“16th”,“17th”,“18th”,“19th”,“20th”,“21st”,“22nd”,“23rd”,“24th”,“25th”,“26th”,“27th”,“28th”,“29th”,“30th”,“31st”];
}
onClipEvent(enterFrame){
now = new Date()
nDay = weekdays[now.getDay()]
nMonth = mon[now.getMonth()]
nDate = daynum[now.getDate()]
nYear = now.getFullYear()
displayDate = nDay+", " + nMonth+" “+ndate+”, "+nYear
displayDay = nDay
}
[/AS]
because
getDate();
returns the actual number of the day. 1, 2, 3, 4.
Since today is the 4th, it returns 4.
Arrays are zero based [0,1,2,3,4,5].
To fix this, either add another entry to the beginning of your array. It can be just a blank space [" ", “1st”, “2nd”…etc]
or use this code:
nDate = daynum[now.getDate() - 1];
ooooo, i see, because an array would start with 0, not 1. so just add something to replace the 0… gotcha, thanks
anytime.
beautiful, worked like a charm.