-
Month problems
HI
im using the following script to get the month and date, im having a slight problem in th at the script returns the wrong month, it returns the month one in front. I can't see my way round this any help please
onClipEvent (load) {
mon = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Oct", "Nov", "Dec"];
weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
}
onClipEvent (enterFrame) {
now = new Date();
nDay = weekdays[now.getDay()];
nMonth = mon[now.getMonth()];
nDate = now.getDate();
nYear = now.getFullYear();
displayDate = nMonth+" "+nDate+", "+nYear;
displayDay = nDay;
}
ps flash mx
-
Senior Member
Arrays are indexed from 0, so that means january isn't month 1, it's month 0.
Use:
nMonth = mon[now.getMonth()-1];
Sam
-
Senior Member
Hold on, just realised that getMonth should return 0 for january anyway.
Sam
-
that code you gave me worked so
cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|