A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Month problems

  1. #1
    God
    Join Date
    Jun 2002
    Location
    Brighton. U.K.
    Posts
    42

    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

  2. #2
    Senior Member SJT's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    2,563
    Arrays are indexed from 0, so that means january isn't month 1, it's month 0.
    Use:
    nMonth = mon[now.getMonth()-1];
    Sam



  3. #3
    Senior Member SJT's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    2,563
    Hold on, just realised that getMonth should return 0 for january anyway.
    Sam



  4. #4
    God
    Join Date
    Jun 2002
    Location
    Brighton. U.K.
    Posts
    42
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center