0

How are you handling Daylight Savings Time with Solspace Calendar event elements?

In our part of the world (America/Detroit), we seasonally offset our clocks by one hour, twice a year.

Let's say we have three events with identical starting times. Two of those events take place after November 3 -- when the time changes.

In the database, these three start dates appear like so:

2022-10-18 18:30:00
2022-11-15 18:30:00
2022-12-06 18:30:00

We parse those out on the front end and the two dates after November 3 display a start time that is offset by one hour.

{% set startDate = event.startDate %}
{{ startDate|date('F jS', timezone='America/Detroit') }}

How is this happening? How might we compensate?

Craft CMS 3.7.56
Solspace Calendar Pro 3.3.16
PHP 7.4.30
MySQL 5.5.5 - 10.83-MariaDB```

1 Answer 1

4

If I'm understanding correctly, the three dates should all appear as the same time on the frontend, as if there was no regional time change?

You can do this by using Calendars .format() method on startDate, like event.startDate.format('F jS') or continue using the |date filter with the event.startDateLocalized property like event.startDateLocalized|date('F jS g:ia', timezone='America/Detroit')

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.