Skip to main content
Participant
October 9, 2007
Question

actionscript for tricky date disply

  • October 9, 2007
  • 2 replies
  • 188 views
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!

This topic has been closed for replies.

2 replies

nade93Author
Participant
October 11, 2007
thank you very much!!!!!
nade93Author
Participant
October 10, 2007
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!
Known Participant
October 10, 2007
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());
}