3 Replies Latest reply on Oct 11, 2007 1:28 AM by nade93

    actionscript for tricky date disply

    nade93
      Hi all

      I am trying to do a newxt day delivery component on my site and trying to find the action scrip for the following (sorry to be a begginer!)

      right basically what i need is the date to bein advance so anything before 11am GMT to have the next day, anything after 11am to have the day after and anything after 11am on a friday to go to monday's date

      can anyone help please? much aprreciated!

        • 1. Re: actionscript for tricky date disply
          nade93 Level 1
          have tried different variations including trace(mydate etc and i cant get anything working. if anyone can help would save me a lot of time ha ha!
          • 2. Re: actionscript for tricky date disply
            Sivakanesh
            Here is a quick outline of code for what you are asking. You should read more on Date object.


            var dt:Date = new Date();
            var hr:Number = dt.getHours();

            if (hr>11){ //After 11AM
            var fridayfactor:Number = 0;
            if (dt.getDay() == 5){ //it's friday
            fridayfactor = 2; //add 2 days to get to Monday.
            }
            var deldate:Date = new Date(dt.getFullYear(), (dt.getMonth()), (dt.getDate() + 2 + fridayfactor));
            trace("It's alredy passed 11 AM. Delvry on " + deldate.getDate() + "-" + (deldate.getMonth()+1) + "-" + deldate.getFullYear());
            }
            else{//before 11 AM
            var deldate:Date = new Date(dt.getFullYear(), (dt.getMonth()), (dt.getDate() + 1));
            trace("It's before 11 AM. Delvry on " + deldate.getDate() + "-" + (deldate.getMonth()+1) + "-" + deldate.getFullYear());
            }
            • 3. Re: actionscript for tricky date disply
              nade93 Level 1
              thank you very much!!!!!