Skip to content

All event times treated as UTC even though timezone set differently #133

Closed

Description

@steveparks

Hello folks,

Thanks for a very useful addon, I'm just configuring it now.

I have one issue to figure out before I go live... and I'm sorry to report that it's (of course) related to timezones !

In my blueprint I have imported your events:event fieldset, including the timezone field.

My server time is set to UTC.

On my test event though, I'm setting the timezone to Europe/London, which is currently on BST (+1 hour from UTC).

I set the start time of the event to 10:00.

If I then display the Start Time in the view with the timezone: {{ start_time | format:'H:i T' }} it displays "10:00 UTC"

So the time field itself isn't reflecting the timezone, and is just (probably) using the server timezone.

If I print out the timezone field to the view, via the {{ timezone | raw }} variable, it shows as "Europe/London"

After a tip from Ryan in Discord I looked at the Statamic Timezone Modifier, but that would actually change the time displayed too, so it would display as "11:00 BST"

I wonder if this issue I'm having could be related to #121 - or am I simply doing something wrong, or misunderstanding the whole thing?

Thanks for any help
Steve

Activity

  1. steveparks commented on Sep 26, 2025

    @steveparks
    Author

    How to reproduce.

    1. Set server time to UTC
    2. Create a test event with a different timezone set in the timezone field.
    3. Output the start time with timezone format n the view {{ start_time | format:'H:i T' }}
  2. steveparks commented on Oct 2, 2025

    @steveparks
    Author

    Chatted this through with @edalzell today and here's what we've found...

    The start_date, start_time, end_date, end_time fields are not timezone aware. So when they are stored and recalled they are just assumed to be in the server timezone.

    Therefore when rendering them in the view, a start time which has 10:00 stored in it, when output formatted as:

    {{ start_time | format('H:i T') }}

    Will always show as 10:00 UTC if the server timezone is set to UTC - even if the timezone on the event is set as Europe/London or elsewhere.

    That then also extends to the calendar downloads, meaning the times will show incorrectly on people's calendars.

  3. steveparks commented on Oct 2, 2025

    @steveparks
    Author

    Within the events addon there is a further 'start' variable which then take the start_date, start_time and timezone and creates a Carbon value with the timezone correctly implemented.

    This could then display timezone aware date/times with {{ start | format('l, jS F Y H:i T') }}

    However due to #134 this variable isn't available on views.

    In addition to resolving that issue, though, could the base start_date and start_time fields be adapted to be timezone aware, based on the timezone in the timezone field?

    That would then solve the related issue that the calendar downloads have incorrect times because of assuming all times are in the server timezone.

  4. steveparks commented on Oct 2, 2025

    @steveparks
    Author

    In the meantime, this is a workaround for displaying times on the event views in the correct timezone as set in the entry timezone field:

    {{ $event_timezone = $timezone | raw }}
    {{ start_info = $start_date + " " + $start_time + " " + $event_timezone}}
    {{ start_info | format('l, jS F Y H:i T') }}
    

    This effectively does the same as the start variable, and so shows that the approach to using Carbon to add the timezone field to the date/time data when creating the variables works.

  5. steveparks commented on Oct 4, 2025

    @steveparks
    Author

    For another workaround, I've reproduced the way start() and end() are built in my EventsCalendarController for creating the google/outlook calendar links with Spatie Calendar Links:

     private function createCalendarLinkObject($event): Link
        {
    
            $startDate = Carbon::parse($event->get('start_date'))
                ->shiftTimezone($event->get('timezone'))
                ->setTimeFromTimeString($event->get('start_time') ?? '00:00');
            
            $endDate = $event->get('end_date') ?
                Carbon::parse($event->get('end_date'))
                ->shiftTimezone($event->get('timezone'))
                ->setTimeFromTimeString($event->get('end_time') ?? '23:59') :
                $startDate->copy()->addHour();
    
    
    

    And that has worked to mean calendar downloads now have the correct times and timezones, and can be localised by the calendar app for the users own timezone

  6. edalzell commented on Feb 6, 2026

    @edalzell
    Member

    Chatted this through with @edalzell today and here's what we've found...

    The start_date, start_time, end_date, end_time fields are not timezone aware. So when they are stored and recalled they are just assumed to be in the server timezone.

    This is correct, start_date is a raw date, and start_time time is a raw string and will use the server timezone.

    If you want timezone aware start/end, use the start and end variables.

  7. edalzell commented on Feb 6, 2026

    @edalzell
    Member

    For another workaround, I've reproduced the way start() and end() are built in my EventsCalendarController for creating the google/outlook calendar links with Spatie Calendar Links:

    Events includes a download tag to make these links.

    Also, use start and end variables that are available on the data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions