# Problem with date

**URL:** <https://forum.kirupa.com/t/problem-with-date/22490>\
**Category:** flash\
**Created:** [June 4, 2003, 6:36pm UTC](https://forum.kirupa.com/t/problem-with-date/22490 "2003-06-04T18:36:17Z")\
**Posts on this page:** 5\
**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:** [June 4, 2003, 6:36pm UTC](https://forum.kirupa.com/t/problem-with-date/22490/1 "2003-06-04T18:36:17Z")

</div>

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]

---

<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:** [June 4, 2003, 6:44pm UTC](https://forum.kirupa.com/t/problem-with-date/22490/2 "2003-06-04T18:44:16Z")

</div>

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];

---

<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:** [June 4, 2003, 6:46pm UTC](https://forum.kirupa.com/t/problem-with-date/22490/3 "2003-06-04T18:46:46Z")

</div>

ooooo, i see, because an array would start with 0, not 1. so just add something to replace the 0… gotcha, thanks

---

<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:** [June 4, 2003, 6:47pm UTC](https://forum.kirupa.com/t/problem-with-date/22490/4 "2003-06-04T18:47:08Z")

</div>

anytime.

---

<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:** [June 4, 2003, 6:47pm UTC](https://forum.kirupa.com/t/problem-with-date/22490/5 "2003-06-04T18:47:19Z")

</div>

beautiful, worked like a charm.
