Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to use date_format() in where condition using laravel

by
Category:laravel
laravel
How to use date_format() in where condition using laravel

In this article, i share with you that how to use date_format() with where condition of Laravel query builder.When i was working on my project, i require to search with get only selected month, year and date records from created_at(timestamp) column. I was thinking how can i but i know date format() of mysql. but don't know how to use in laravel where clause. At last i use DB::raw() of Laravel and its work.

$getdata = DB::table('login_history')
  	->where(DB::raw("(DATE_FORMAT(created_at,'%Y-%m-%d'))"),date('Y-m-d'))
   ->get();

0 Comments


Html code work in comment box


Related Post