我需要在21.45到10.00之后重定向到页面
问题描述:
I need to do a site redirects to a page after 21.45 to 10.00 I need a script that would do a redirect site to another page at a certain time.
Here's what happened.
<?php
$date = new DateTime('now');
$date->setTimezone(new DateTimeZone('Europe/Athens'));
if ($date->format('H')>=10 && $date->format('H')<=21 ){
if ($date->format('H')==21 && $date->format('i')<45)
echo "<script>window.location = '/'</script>";
else if($date->format('H')<21)
echo "<script>window.location = '/'</script>";
}
?>
我需要在21.45到10.00之后将网站重定向到页面 我需要一个可以重定向的脚本 在某个时间站点到另一个页面。 p>
这是发生了什么。 p>
&lt;?php
$ date = new DateTime( 'now');
$ date-&gt; setTimezone(new DateTimeZone('Europe / Athens'));
if($ date-&gt; format('H')&gt; = 10&amp;&amp; $ date - &gt;格式('H')&lt; = 21){
if($ date-&gt; format('H')== 21&amp;&amp; $ date-&gt; format('i')&lt; 45)
echo“&lt; script&gt; window.location ='/'&lt; / script&gt;”;
否则if($ date-&gt; format('H')&lt; 21)
echo“&lt; script&gt; window.location ='/'&lt; / script&gt;”;
}
?&gt;
code> pre>
div>
答
Not really sure with timezone, but
$hoursMinutes = intval(date("Hi"));
if($hoursMinutes >= 1000 && $hoursMinutes <=2145) {
header("Location: /2");
} else {
header("Location: /1");
}