Laravel & Php

Laravel queries Tips


Laravel queries Tips

Quick Laravel queries tips

Laravel – where less/greater than date syntax

$date = "2021-03-25";    // Format: date('Y-m-d);

$orders = DB::table('table_name')
               ->select('*')
               ->whereDate('field_name', '<=', $date)
               ->get();

// Here, Table Field type is "datetime or date"
// Assuming DB `field_name` stores value format like: "Y-m-d H:i:s or Y-m-d"

Date time DB Laravel
Share with Friends

Like this chef? Share with friends..