How to Get Current Year Data from database In CodeIgniter
This page all about how to get/fetch current year data from the database in Codeigniter. We have seen many developers get confused to get records from MySQL table for the current year in PHP. Here You will get a very simple way to find the solution.
Have a look below example.
Let the table name be “Tbl_name” and date column be paid_date. Now We have an in-bulilt function to get day, month, year by using date() function, passing the parameter like m,d, Y, etc..
1 2 3 |
$this->db->select('Tbl_name'); $this->db->where('YEAR(paid_date)', date('Y')); $this->db->get(); |