Default date and time format in v4 #18254
Replies: 5 comments 2 replies
-
|
Instead of define the default formatting why don't mutate the format ? |
Beta Was this translation helpful? Give feedback.
-
|
This is either a bug caused by forgotten code or a misunderstanding of the feature. I looked at the docs, and I don't really see any mention of this, so I'm leaning toward the former. |
Beta Was this translation helpful? Give feedback.
-
|
It was a thing in v3 #7699 (comment) It was actually fairly helpful thing - I'd set-and-forget my formats to be jS M y H:i for the tables and would never have to worry again. |
Beta Was this translation helpful? Give feedback.
-
|
Quite a bummer that the properties were made protected and there's no static method to receive the default date/time formats. public function table(Table $table): Table
{
return $table->columns([
IconColumn::make('featured_at')
->tooltip(fn($state) => $state?->format(Table::$defaultDateDisplayFormat)),
]);
}with public function table(Table $table): Table
{
return $table->columns([
IconColumn::make('featured_at')
->tooltip(fn($state) => $state?->format($table->getDefaultDateDisplayFormat())),
]);
} |
Beta Was this translation helpful? Give feedback.
-
|
you can do this inside a panel provider or in the app service provider ->bootUsing(function () {
Table::configureUsing(fn(Table $table) => $table
->defaultCurrency('eur')
->defaultDateDisplayFormat('d-m-Y')
->defaultDateTimeDisplayFormat('d-m-Y H:i')
->paginationPageOptions([25, 50, 100, 'all']));
.... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Package
Panel builder
Package Version
v4
How can we help you?
Hello! In v3 I used global date and time formatting like this:
Table::configureUsing(fn (Table $table) => $table->defaultTimeDisplayFormat('H:i'));
Table::configureUsing(fn (Table $table) => $table->defaultDateTimeDisplayFormat('M j, Y H:i'));
Also I used values of these properties in my own helper functions:
Table::$defaultTimeDisplayFormat;
Table::$defaultDateTimeDisplayFormat;
Table::$defaultDateDisplayFormat;
The same for Infolists.
But in v4 it does not work. How can we configure default date and time formatting now?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions