How to get current month data in MySql PHP ?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Today now in this post i will show you how to get current month date in mysql in php . If we need to get all the records of current month by using mysql query. For example we have one table as name “items” and columns are id, title,created_at and also update_at, Now we want to get all records of this month. so now we can fetch the fields value by using DATE_SUB and INTERVAL of mysql. So now in the following example we can see how to select data of current month.

Example:

SELECT * FROM items WHERE created_at > DATE_SUB(NOW(), INTERVAL 1 MONTH);

Read Also : Laravel chat message module using socket.io and nodejs

Thanks for read. I hope it help you. For more you can follow us onĀ facebook.

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →