if(){
header ('Location: http://www.misitio1.com');
}else{
header ('Location: http://www.misitio2.com');
}
我到现在为止。如何为条件添加时间,当秒或分钟为偶数时,重定向到site1,奇数重定向到site2。
答案 0 :(得分:1)
试试这个
$time = strtotime("now"); // You will get the current time in UNIX timestamp..
if(($time%2)==0){
header ('Location: http://www.misitio1.com');
}else{
header ('Location: http://www.misitio2.com');
}
如果您想处理当前小时或分钟的值,
$hr = date("H"); //Change it depending on your wish, 12 hr or 24 hr time. This will return 24 hr time.
$min = date("i");
if((($hr%2)==0) || (($min%2)==0)){ //You can add condition as per your requirment
header ('Location: http://www.misitio1.com');
}else{
header ('Location: http://www.misitio2.com');
}