我想比較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');
什麼解決辦法嗎?