Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timezone #34

Closed
invaders-xx opened this issue Aug 1, 2022 · 7 comments · Fixed by #55
Closed

Timezone #34

invaders-xx opened this issue Aug 1, 2022 · 7 comments · Fixed by #55

Comments

@invaders-xx
Copy link
Contributor

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

@saade
Copy link
Owner

saade commented Aug 1, 2022

do you have a column timezone in your users database?

@invaders-xx
Copy link
Contributor Author

Of course ;-)

@invaders-xx
Copy link
Contributor Author

I think you didn't implement momentTimezonePlugin : Timezone

@saade
Copy link
Owner

saade commented Aug 3, 2022

I think Timezone is already included on the global build?

@invaders-xx
Copy link
Contributor Author

Maybe but I need to convert all dates (which care stored in UTC) in the user's timezone to display rightly.

@tiagof
Copy link
Contributor

tiagof commented Aug 28, 2022

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 😓)

@saade saade mentioned this issue Sep 25, 2022
@saade saade closed this as completed in #55 Sep 25, 2022
@saade
Copy link
Owner

saade commented Sep 25, 2022

@invaders-xx @tiagof please try this new release and see if the timezone issue still appears

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants