Search code examples
laravel-nova

Laravel Nova set global DateTime format


Is there a way to set formatting on a global level for Laravel Nova?

Currently I have to do something like this all over the place:

DateTime::make('Created At')->sortable()->format('D-M-yyyy H:m'),

Preferably I would just want all DateTime instances to be formatted like this.


Solution

  • I would suggest extending the default DateTime field to App\Nova\Fields\DateTime and you can have more control on how to define the default for each project.

    https://crynobone.com/extending-default-fields-on-laravel-nova/