Php 检查验证日期是否为<;三个月

Php 检查验证日期是否为<;三个月,php,codeigniter,validation,date,Php,Codeigniter,Validation,Date,我想从这个案子中得到证实。如果输入日期小于现在。因此,它将导致一个警报并重定向到主页。这是我写的,但没用 $dateEntry = array($current_employee->emp_dtentry); if ($dateEntry < strtotime('+3 months')) { echo "<script>alert('you don't have the right to access this

我想从这个案子中得到证实。如果输入日期小于现在。因此,它将导致一个警报并重定向到主页。这是我写的,但没用

        $dateEntry = array($current_employee->emp_dtentry);

        if ($dateEntry < strtotime('+3 months')) {
            echo "<script>alert('you don't have the right to access this menu')</script>";
            redirect('new_leave','refresh');
        }
$dateEntry=array($current\u employee->emp\u dtentry);
如果($dateEntry<标准时间('+3个月')){
echo“警报('您无权访问此菜单')”;
重定向('new_leave','refresh');
}

感谢您的帮助,谢谢

将日期放入数组,然后将其与时间戳进行比较。你为什么这么做

假设
$current\u employee->emp\u dtentry
是Unix时间戳:

if ($current_employee->emp_dtentry < strtotime('+3 months')) {

当您重定向时,您的回音将无法工作。要么刷新javascript,要么在那里使用javascript重定向

使用flash:

 $dateEntry = $current_employee->emp_dtentry;
 if ($dateEntry < strtotime('+3 months')) {
    $this->session->set_flashdata("javascript", "<script>alert('you don't have the right to access this menu')</script>");
    redirect('new_leave');
 }
或者使用javascript按如下方式执行:

 $dateEntry = $current_employee->emp_dtentry;
 if ($dateEntry < strtotime('+3 months')) {
    echo "<script>alert('you don't have the right to access this menu'); window.location.href='new_leave';</script>";
 }
$dateEntry=$current\u employee->emp\u dtentry;
如果($dateEntry<标准时间('+3个月')){
echo“警报('您无权访问此菜单”);window.location.href='new_leave';
}

如果条件允许,它将进入内部?是的,我做错了什么吗?:(
$current\u employee->emp\u dtentry
的值是多少?您正在将
$dateEntry
初始化为数组,但没有在if语句中对其进行索引。是的,这是我的错误。感谢您指出:)啊,我明白了,所以它不会重定向。谢谢你的信息。我很感激!
 $dateEntry = $current_employee->emp_dtentry;
 if ($dateEntry < strtotime('+3 months')) {
    $this->session->set_flashdata("javascript", "<script>alert('you don't have the right to access this menu')</script>");
    redirect('new_leave');
 }
if($this->session->flashdata('javascript')){
    echo $this->session->flashdata('javascript');
}
 $dateEntry = $current_employee->emp_dtentry;
 if ($dateEntry < strtotime('+3 months')) {
    echo "<script>alert('you don't have the right to access this menu'); window.location.href='new_leave';</script>";
 }