I have multiple pages for different communities from different timezones that are supposed to show their events with localized time. Each community has their own data/yaml file with events including start date and time.
For example, one such start time entry looks like “2025-05-17T13:00:00Z”, i.e. it is represented in UTC.
For each community page I want to specify the corresponding timezone, e.g. “Europe/Berlin” to render the start datetime in a localized and daylight savings time aware manner in the corresponding timezone.
However, when I do {{ time "2025-05-17T13:00:00Z" "Europe/Berlin" }}, I get 2025-05-17 13:00:00 +0000 UTC and not the correct localized datetime.
Also, {{ (time "2025-05-17T13:00:00Z").In "Europe/Berlin" }} fails with can't handle "Europe/Berlin" for arg of type *time.Location, which when changed to {{ (time "2025-05-17T13:00:00Z").In (time.LoadLocation "Europe/Berlin") }} just results in the next error can't evaluate field LoadLocation in type interface {}
I added another example at the bottom of the home page on the example site. Try it:
git clone --single-branch -b hugo-forum-topic-41863 https://github.com/jmooring/hugo-testing hugo-forum-topic-41863
cd hugo-forum-topic-41863
hugo server
Note that displaying time without date may be insufficient depending on source and target time zones (e.g., time.Now may be tomorrow somewhere else).