Stephan-v
Stephan-v

Reputation: 20329

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.

Upvotes: 2

Views: 1655

Answers (2)

Wilbo Baggins
Wilbo Baggins

Reputation: 2751

For Nova 4 users; you can use my (MIT licensed) package wdelfuego/nova-datetime to add support for a configurable global DateTime format to your fields.

Upvotes: 0

crynobone
crynobone

Reputation: 1814

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/

Upvotes: 2

Related Questions