Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

LawrenceSmith's avatar

Show Current Date/Time on Filament Dashboard

Hi

As per the title, I'm wanting to add the current date and time to a dashbord. Any ideas or know of any plugins available to do this?

Thanks

0 likes
7 replies
LaryAI's avatar
Level 58

To display the current date and time on a Filament dashboard, you can create a custom widget. Filament allows you to create custom widgets by extending the Widget class. Here's a simple example of how you can create a widget to show the current date and time:

  1. Create a new widget class. You can place this file in the app/Filament/Widgets directory or any other directory where you organize your Filament widgets.
namespace App\Filament\Widgets;

use Filament\Widgets\Widget;
use Carbon\Carbon;

class CurrentDateTimeWidget extends Widget
{
    protected static string $view = 'filament.widgets.current-date-time-widget';

    public function getCurrentDateTime()
    {
        return Carbon::now()->toDayDateTimeString();
    }
}
  1. Create a Blade view for the widget. Create a new Blade file named current-date-time-widget.blade.php in the resources/views/filament/widgets directory.
<div class="card">
    <div class="card-body">
        <h5 class="card-title">Current Date & Time</h5>
        <p class="card-text">{{ $this->getCurrentDateTime() }}</p>
    </div>
</div>
  1. Register the widget in your Filament dashboard. Open the FilamentServiceProvider (or create one if it doesn't exist) and register the widget in the boot method.
namespace App\Providers;

use App\Filament\Widgets\CurrentDateTimeWidget;
use Filament\FilamentServiceProvider as BaseFilamentServiceProvider;
use Filament\Widgets\Widget;

class FilamentServiceProvider extends BaseFilamentServiceProvider
{
    protected function getDashboardWidgets(): array
    {
        return [
            // ... other widgets
            Widget::make(CurrentDateTimeWidget::class),
        ];
    }
}
  1. Make sure to import the Carbon facade at the top of your widget class if you haven't already:
use Carbon\Carbon;

Now, when you visit your Filament dashboard, you should see the widget displaying the current date and time. Remember that the time shown will be based on the server's timezone settings unless you specify a different timezone using Carbon's methods.

jaseofspades88's avatar

All you would really need to do is return now()->format('H:i');, @LawrenceSmith and poll on that. Each time the component reloads, the date updates. Just change the format for the one you actually want.

jaseofspades88's avatar
Level 51

If your question has been answered, can you close the thread, please and thank you

Please or to participate in this conversation.