I'm using a CodeIgniter framework and uses jQuery and ajax to insert data from inputs. The problem is the date changes when I process it in ajax. Im using MySQL for the database and the data type is Date.
I've tried to change formats for the date because it might not be the same format.
Jquery/Ajax:
$(document).on('submit', '#insertQL_form', function(event){
event.preventDefault();
var month = $('#datetimepicker1').val();
var nameCompany = $('#nameCompany').val();
var email = $('#email').val();
var position = $('#position').val();
var ojLink = $('#ojLink').val();
var remarks = $('#remarks').val();
var withTestTask = $('#withTestTask').val();
var testTaskStatus = $('#testTaskStatus').val();
var withInterview = $('#withInterview').val();
var overallStatus = $('#overallStatus').val();
alert(month);
$.ajax({
url:"<?php echo base_url() . 'home/insertQL'?>",
method:'POST',
data: new FormData(this),
contentType:false,
processData:false,
success:function(data)
{
alert(data);
}
});
});
Controller Function:
public function insertQL()
{
if($_POST["action"] == "Add")
{
$insert_data = array(
'month' => date("Y-m-d",$this->input->post('month')),
'nameCompany' => $this->input->post('nameCompany'),
'email' => $this->input->post('email'),
'position' => $this->input->post('position'),
'ojLink' => $this->input->post('ojLink'),
'remarks' => $this->input->post('remarks'),
'withTestTask' => $this->input->post('withTestTask'),
'testTaskStatus' => $this->input->post('testTaskStatus'),
'withInterview' => $this->input->post('withInterview'),
'overallStatus' => $this->input->post('overallStatus')
);
$this->load->model('QLModel');
$this->QLModel->insert_crud($insert_data);
echo 'Data Inserted';
}
}