Laravel date comparision

There are many ways to display date and format like using PHP date function.But i think it will be better to use included package.

By default laravel comes withe Carbon package.It is a simple PHP API extension for DateTime.

You need to add Carbon\Carbon namespace where you want use it like below:

Here i am going to show you laravel eloquent Date comparision whereDate / whereMonth / whereDay / whereYear.

1.Fetch all records from users table where date is equal to current date.

2.Fetch all records from users table where month is equal to current month.

3.Fetch all records from users table where day is equal to particular day of a month.

4.Fetch all records from users table where year is equal to current year.

Gaurav Kumar

Hi, my name is Gaurav Kumar and I specialize in Computer Software industry. I have been working as a Software Developer from last 3+ years,and its my passion to learn new technology and sharing what I've learned.