asp的限制时间访问时这样写的:
<%
If WeekDay(Date,1)>1 And WeekDay(Date,1)<7 Then '判断是否周末
    If ( DateDiff("n",Time,"0:01:00")<=0 And DateDiff("n",Time,"8:00:00")>=0 ) Or (DateDiff("n",Time,"18:30:00")<=0 And DateDiff("n",Time,"23:59:00")>=0) Then '判断是否上班时间
         Response.Write"<script>alert('现在是["&Now&"]\n\n该页面禁止访问,请在工作时间来!');window.document.location.href='http://www.huiyoo.com.cn';</script>"
:Response.End
    End If
End If
%>不知道PHP的应该怎么写啊?请教各位高手!

解决方案 »

  1.   

    可参考手册中的date函数,oop的话DateTime类
      

  2.   

    不太懂asp,楼主的意思似乎是星期天数如果>1,<7,时间0-8点,18:30-23:59禁止访问吧?
    那也许可以用下面的代码实现
    <?php
    $tmDay = date ( 'j' );
    $tTime = date ( 'H:m:s' );
    echo $tmDay . "<br>";
    echo $tTime;
    if ($tmDay > 1 && $tmDay < 7) {
    if (($tTime > '08:00:00' && $tTime < '00:00:00') || ($tTime > '18:30:00' && $tTime < '23:59:00'))
    echo "<script language=\"javascript\">alert(\"现在是" . $tTime . "该页面禁止访问,请在工作时间来!\");</script>";
    }
    ?>