ExportColumn date format

Is there a way to fix a date format into a specific format - like m/d/y H:i when exporting? I have reports that show the date in one way but then when they export the end user is getting 24 hour military times . . . I need an easy button for them.
3 Replies
HeartlandTechie
HeartlandTechie3mo ago
Is there a specific date example for this? Also (and related) if the export fails . . . the queue never stops running on export . . . it just gives you error messages and ignores the attempts column . . . anyone else hit this?
toeknee
toeknee3mo ago
You should be trying/catching where needed, sounds like your causing an ifinitely loop.
use Filament\Actions\Exports\ExportColumn;

ExportColumn::make('status')
->formatStateUsing(fn (string $state): string => __("statuses.{$state}"))
use Filament\Actions\Exports\ExportColumn;

ExportColumn::make('status')
->formatStateUsing(fn (string $state): string => __("statuses.{$state}"))
Above is from the docs, standard php just do similar to format as Y-m-d
use Filament\Actions\Exports\ExportColumn;

ExportColumn::make('date')
->formatStateUsing(fn ($state) => Carbon::hasFormat($state, 'Y-m-d H:i:s') ? Carbon::parse($state)->format('Y-m-d') : 'Invalid Date' )
use Filament\Actions\Exports\ExportColumn;

ExportColumn::make('date')
->formatStateUsing(fn ($state) => Carbon::hasFormat($state, 'Y-m-d H:i:s') ? Carbon::parse($state)->format('Y-m-d') : 'Invalid Date' )
Want results from more Discord servers?
Add your server