Search code examples
laravellaravel-5laravel-nova

Laravel Nova: Convert Datetime to readable output


Is there an option in Laravel Nova to display an readable date-time output and/or limit the output?

For example to : 29. October 2018 / 11. November 2018, 12:10 am

Datetime

Code:

   DateTime::make('Start')
                ->rules('required')
                ->sortable(),

Solution

  • This is achieved in Nova 4.0+ with the displayUsing method:

    DateTime::make('Updated', 'updated_at')
    ->displayUsing(fn ($value) => $value ? $value->format('D d/m/Y, g:ia') : '')