Home > Blockchain >  casts property is not working to change date format
casts property is not working to change date format

Time:03-16

I am trying to change date format while fetching data in this way

 protected $casts = [
        'due_date' =>  'date:d-m-Y',
     
    ];

Blade

{{$ticket->due_date}}

It is showing is like

2022-03-13

CodePudding user response:

Casts are for json serialization (json_encode($ticket)). To get the format you want in blade, use Carbon's format method.

{{ $ticket->due_date->format('d-m-Y') }}
  • Related