PHP code example of relisiuol / filament-relative-time
1. Go to this page and download the library: Download relisiuol/filament-relative-time library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
relisiuol / filament-relative-time example snippets
use Relisiuol\FilamentRelativeTime\RelativeTimePlugin;
public function panel(\Filament\Panel $panel): Panel
{
return $panel->plugins([
RelativeTimePlugin::make(),
]);
}
use Relisiuol\FilamentRelativeTime\Columns\RelativeTimeColumn as RT;
RT::make('created_at')
->label('Created')
->format('relative') // relative | datetime | duration
->precision('minute') // for relative/duration
->threshold('P30D') // ISO8601 – switch to absolute after 30 days
->timeZone('auto') // 'auto' (browser) or 'Europe/Paris'
->locale('en-GB') // otherwise <html lang> / browser
->datetimeIntl([ // only when format='datetime'
'year' => 'numeric',
'month' => 'short',
'day' => '2-digit',
'hour' => '2-digit',
'minute' => '2-digit',
'time-zone-name' => 'short',
])
->formatStyle('short') // 'long' | 'short' | 'narrow'
->tense('auto') // 'auto' | 'past' | 'future'
->absolutePrefix('on') // override default absolute prefix
->noTitle() // drop <relative-time> title attribute
->elementAttributes(['aria-label'=>'Creation date']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.