-1

I have been using this as3 code but would like to know if its possible to do in php or JavaScript as I cant seem to find anything. regards

var my_date:Date; 
var my_timer:Timer=new Timer(1000);
my_timer.addEventListener(TimerEvent.TIMER, onTimer);
my_timer.start(); 

function onTimer(e:TimerEvent):void {
my_date = new Date();
var dayOfWeek_array:Array = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var today_date:Date = new Date();
var day_str:String = dayOfWeek_array[today_date.getUTCDay()];
//trace("Today is "+day_str + " and the Hour is "+today_date.getUTCHours());

if(dayOfWeek_array[today_date.getUTCDay()] == "Sunday" && today_date.getUTCHours() >= 08 && today_date.getUTCHours() <= 09)
{
//load page1
}

else if(dayOfWeek_array[today_date.getUTCDay()] == "Sunday" && today_date.getUTCHours() >= 10 && today_date.getUTCHours() <= 11)
{
//load page2
}
else
{
//load page0
}
}
4

1 回答 1

1

Sure it's possible. You can't make the PHP automatically update it when the day changes, but you can have the PHP code check once when serving the page to the user, and then have JavaScript refresh when the date or time goes over one of the boundaries.

In PHP, you'll want to look into the date function.
In JavaScript, you'll want to look into setInterval, Date, and location.reload.

于 2013-03-31T02:01:20.057 回答