我想比较start date
和end date
,但它在同一个月工作。但我输入两个不同的月份是不行的。比较两个日期不能正常工作
对于恩:我进入start date= 23/12/2013
和End date=06/12/2013
它会工作,但我进入Start date = 23/12/2013
和End date=01/01/2014
它会给同样的错误。
型号:
public function _date(){
$startDate = strtotime($this->input->post('start_date'));
$endDate = strtotime($this->input->post('end_date'));
if ($endDate >= $startDate)
return True;
else {
return False;
$this->form_validation->set_message('compareDate', '%s should be greater than Contract Start Date.');
}
return False;
}
控制器:
function date_validation(){
$isDate = $this->mdl_education->_date();
$data['emp_id'] = $this->input->post('emp_id',TRUE);
if($isDate)
{
$this->session->set_flashdata('msg', 'Please Enter valid Date ');
redirect("education/form/".$data['emp_id']);
}
}
$this->form_validation->set_rules('end_date', 'End Date', 'trim|required|xss_clean|callback_date_validation');
什么解决办法吗?