我一直在使用这个as3代码,但想知道它是否可以用php或JavaScript做,因为我似乎无法找到任何东西。问候
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
}
}
答案 0 :(得分:1)
当然有可能。当白天更改时,您无法让PHP自动更新它,但您可以在向用户提供页面时检查一次PHP代码,然后在日期或时间超过其中一个边界时刷新JavaScript。 / p>
在PHP中,您需要查看the date
function
在JavaScript中,您需要查看setInterval
,Date
和location.reload
。