I'm trying to store the current date and time in a MySQL database, but when storing it stores in a different format:
I'm using
date("Y-m-d H:i:s");
But it's stored as
20/16/1017
It should be
2016-10-17 15:23:23
View
$date = date("Y-m-d H:i:s");
<input type="hidden" name="date" id="date" value="<?php echo $date; ?>">
Model
function InsertAdd($data)
{
$this->db->insert('advertisements', $data);
}
Controller
$data = array(
'Date' => $this->input->post('date'),
);
Note: - i have changed my type to datetime and default is currenttime in mysql db