format datetime laravel code example

Example 1: Date time format for laravel validation

$request->validate([
        'start_date' => 'date_format:d/m/Y',
        'end_date' => '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)) }}

Example 4: laravel date format valdiate

'date_format:d/m/Y';

Tags:

Php Example