laravel datetime format code example

Example 1: carbon date from format

Carbon::createFromFormat('Y-m-d H:i:s', $request->date)->format('d-m-Y')

Example 2: datetime format laravel

//laravel method 1
{{ $data->created_at->isoFormat('dddd D') }}

//laravel method 2 
{!! date('d/M/y', strtotime($data->created_at)) !!}

Example 3: format time laravel

{{\Carbon\Carbon::createFromFormat('H:i:s',$time)->format('h:i')}}

{{$item->date_seance->format('d/m/Y') }}

{{date('H:i', strtotime($item->start_time)) }}

Tags:

Php Example