How to change date format in laravel Query Builder from "2016-03-12" to "12-Mar-2016"
Try to use this:
$results = DB::table('customers as cust')
->where('cust.id',$id)
->select(DB::raw('DATE_FORMAT(cust.cust_dob, "%d-%b-%Y") as formatted_dob'))
->first();
As there is no way except using raw query, I am using like this. It worked for me.
->select("cust.*", DB::raw("DATE_FORMAT(cust.cust_dob, '%d-%b-%Y') as formatted_dob"))
Laravel use Carbon for datetime so you can write it like following code:
$results = DB::table('customers as cust')
->where('cust.id',$id)
->select("cust.*","cust.cust_dob as dob")
->first();
echo $results->dob->format('d-m-Y');