onlinecode

How to get current month in Codeigniter?

How to get current month in Codeigniter?

In this post we will give you information about How to get current month in Codeigniter?. Hear we will give you detail about How to get current month in Codeigniter?And how to use it also give you demo for it if it is necessary.

In this example, we will learn how to get current month data in codeigniter. we can get current month data using codeigniter query builder. we will use MONTH() and YEAR() mysql function for getting current month data.

I will share with you simple example example of getting current month data in codeigniter 3 application. sometime it might be require to get and display only current month data in your php codeigniter 3 application.

You can see bellow example database query to getting current month data from database items table.

Example:

$data['data'] = $this->db->select('*')

->where('MONTH(created_at)', date('m'))

->where('YEAR(created_at)', date('Y'))

->get("items")

->result();

print_r($data['data']);

exit;

Output:

Also see:How to fetch single row from database in php codeigniter?

Array

(

[0] => stdClass Object

(

[id] => 2

[title] => Codeigniter 3 CRUD Example

[description] => Codeigniter 3 CRUD Example From Scratch To follow : Itsolutionstuff.com

[created_at] => 2019-07-11 00:00:00

[updated_at] => 0000-00-00 00:00:00

)

)

I hope it can help you….

Hope this code and post will helped you for implement How to get current month in Codeigniter?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Exit mobile version