[Solved] Date format with codeigniter


The problem is hidden in the error message. Take a look at your SQL query syntax:

DATE_FORMAT(news_articles'.date_posted', `'%M` %D, `%Y')`

That doesn’t look right, does it?

Because CI is trying to auto-protect your column names. So, to fix this, you need to pass FALSE to the second parameter of $this->db->select(), which will stop CI from trying to auto-protect these names.

This should work:

$this->db->select("DATE_FORMAT(".$this->news_articles_table.".date_posted, '%M %D, %Y')", FALSE);

solved Date format with codeigniter