laravel where date today code example

Example 1: get current date laravel

use Carbon\Carbon;
$date = Carbon::now();

Example 2: laravel where creation is today carbon

$posts = Post::whereDate('created_at', Carbon::today())->get();

Example 3: laravel where created_at today

$posts = Post::whereDate('created_at', Carbon::today())->get();

Example 4: where('created_at', '=', date('Y-m-d'));

$q->whereDay('created_at', '=', date('d'));
$q->whereMonth('created_at', '=', date('m'));
$q->whereYear('created_at', '=', date('Y'));

Example 5: where('created_at', '=', date('Y-m-d'));

$q->where('created_at', '>=', date('Y-m-d').' 00:00:00'));

Tags:

Php Example