filament-fullcalendar
filament-fullcalendar copied to clipboard
Timezone
My event's dates (start and end) are stored in database in UTC. But I want to display those dates using user's timezone.
So I have a resource's view showing events table : as you can see the dates in table are displayed using the right timezone. In the FullCalendar, we see that event are displayed using UTC event if i set :
public function getConfig(): array
{
return array_merge(parent::getConfig(), [
'timeZone' => auth()->user()->timezone,
'locale' => app()->getLocale(),
]);
}
![image](https://user-images.githubusercontent.com/604907/182158677-785fe703-a6de-4f5a-9228-e3cb1c280d4d.png)
do you have a column timezone
in your users
database?
Of course ;-)
I think you didn't implement momentTimezonePlugin : Timezone
I think Timezone is already included on the global build?
Maybe but I need to convert all dates (which care stored in UTC) in the user's timezone to display rightly.
Hi @invaders-xx
Did you solve this?
My progress:
From full-calendar docs: https://fullcalendar.io/docs/timeZone the timezones are NOT converted unless a timezone plugin is used, except for the local
timezone.
In my case, since my dates are all Carbon objects and reach the Fullcalendar script with the timezone part:
Array(1)
0:
description: "....."
end: "2022-08-27T17:30:00.000000Z"
id: 15
orderStrict: true
start: "2022-08-27T15:00:00.000000Z"
title: "Test event"
if I use timeZone => 'local'
in config/filament-fullcalendar.php
<?php
/**
* Consider this file the root configuration object for FullCalendar.
* Any configuration added here, will be added to the calendar.
* @see https://fullcalendar.io/docs#toc
*/
return [
'timeZone' => 'local',
'locale' => config('app.locale'),
...
It converts the events time to the user's timezone automatically.
Of course this doesn't use the $user->timezone
property as you have it, but it displays the events in whatever timezone the user's browser/OS it set to.
(#48 was created to fix an exception when we explicitly set the timeZone
to local
😓)
@invaders-xx @tiagof please try this new release and see if the timezone issue still appears