this code implement function in controller file :-
class date extends Controller
{
function index()
{
$data['error']=”";
$this->load->view(‘date’,$data);
}
function validation ()
{
$dft= trim($this->input->post(‘datefrom’));
list($m, $d, $y) = explode(‘/’, $dft);
$dtt=trim($this->input->post(‘dateto’));
list($m1, $d1, $y1) = explode(‘/’, $dtt);
$Ins=”false”;
if($y<$y1) // greater than year
{
$Ins=”true”;
}
elseif ($y==$y1) // equal to year
{
if($m<$m1) // greater than month
{
$Ins=”true”;
}
elseif($m==$m1) // equal to month
{
if($d<$d1)
{
$Ins=”true”;
}
else
{
$data['error']==’Please Enter Grater than date of From time’;
}
}
else
{
$error=’Please Enter Grater than date of From time’;
}
}
else
{
$data['error']==’Please Enter Grater than date of From time’;
}
if($Ins==”true”)
{
$data['error']=”Date is true ”
}
else
{
$this->load->view(‘date’,$data)
}
}
}
view file :- date.php
<html>
<?php echo form_open_multipart(‘date/validation/’);?>
From Time<input type=”text” name=”datefrom” /> // Date format MM/DD/YYYY
To Time<input type=”text” name=”dateto” /> // Date format MM/DD/YYYY
<?php $error?>
<?php echo form_close();?>
</html>