Reputation: 1
This is the model used to store the date.
public function add_client() {
$sqlDaye = "YYYY-MM-DD";
$data = array(
'name' => $this->input->post('client_name'),
'industry_id' => $this->input->post('industry'),
'user_id' => $this->input->post('users'),
'status_id' => $this->input->post('status'),
'startdate' => date("Y-m-d H:i:s", strtotime(str_replace('/', '-', $sqlDaye))),
'enddate' => date("Y-m-d H:i:s", strtotime(str_replace('/', '-', $sqlDaye))),
'rates' => $this->input->post('rates')
);
$this->db->insert('clients', $data);
}
Upvotes: 0
Views: 233
Reputation: 2148
$sqlDaye = "YYYY-MM-DD";
Is a string.
You cannot enter a string into a date. '2014-11-10' is a date.
Upvotes: 0
Reputation: 46900
$sqlDaye = "YYYY-MM-DD";
YYYY-MM-DD
is a valid format, not a valid date. And you are running strtotime
on it which results in an invalid timestamp and the you get the default value returned
strtotime
The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given in now, or the current time if now is not supplied.
You have to run that on a date, not on a format. Like try this
echo date("Y-m-d H:i:s", strtotime('2014-10-10'));
^
Upvotes: 2