I need dates to display in their correct timezone

Hi, I have been using Jekyll for years, but most of my site’s content is meant for consumption in the Pacific Northwest (America/Los_Angeles) and so I have not run into the problem that I am now experiencing.

I have a site, for an author based here in the PNW who must go on a book tour.

# _config.yaml

Timezone: America/Los_Angeles

She would like to announce events on her website - and so I have set up the following:

#_posts/2024-01-27-post-title.md

---
title: "Post Title"
date: 2024-01-27T00:00 America/Los_Angeles

event-date: "2024-02-05 20:00 America/New_York"
---

and…

#_layouts/post.html

~
{{ page.event-date | date: "%b %d, %Y %I:%M %p %Z %z" }}
~

note: I am displaying both the TZ Label (%Z) and the TZ 0ffset (%z%) for debugging purposes only.

The output of this is: Feb 05, 2024 08:00 PM PST -0800

I arrived at using IANA timezone designators for each of these time values because of this post: Timezone global configuration problem Which I found allowed me to display PST rather than -0800 etc… Prior to that I was using numeric timezone offsets (-0800, -0500 etc and I found those to be confusing to folks reading the site – so labels like PST and EST are more desirable.

Anyway, if you look at the config.yml and at the post you should see that I have designated different timezones and so I expect Jekyll to either give me output appears in Pacific Time (-0800)
Feb 05, 2024 05:00 PM PST -0800

OR better, I expect output in Eastern Time (-0500)
Feb 05, 2024 08:00 PM EST -0500

Now, I have read that Jekyll when configured properly will only show times in the timezone configured in _config.yml and that would meet my first expectation - except that Jekyll is not doing the math to display 5 PM pacific.

So, I guess my question is, what am I doing wrong here for Jekyll to not be doing the math and giving me the correct time in PST.

My second question (icing on the cake) is is there a way I can get the event date to appear in the event’s local timezone?

Thanks for you help in advance.

Bill

what happens if you remove the quotes? with quotes the date is a string and without I think it is a date - not a string.

The post you referenced has a link to a still open issue/bug in the jekyll repo.

I would hard code the dates as you want them to show - I would think that is the safest way to go about it.

Without quotes around the IANA timezones results in the same thing. I agree the quotes should not be there - and at one point in my journey they weren’t.

I want it as a date time object because I do do some math around it later - if it has been three days since and event occurred, I want to pull it form the front page and move it to the archive. The site is built at midnight every morning, so things will fall off the front page as time goes on.

gotcha.

Maybe code the date as it would be in the time zone of the server? then it is at least correct. Looks weird at the location though and I am sure the client won’t like it assuming the events could be anywhere.

Your use case of events rolling off the home page as they expire is fairly common - I have seen posts about that before, not sure any of them were your specific problem.

My guess is that bug linked to in the other thread has the same issue and it is an issue in jekyll - though I did not read it well enough to understand it. That is just a guess though, I would keep poking around and see if you can find someone else who has a solution.

or maybe another idea is to have 2 front matter variables - one for the date and another for the actual date in the location as you want it to show - the first one is what gets checked by the code to control what shows on the home page, the other is what actually is used in the content. A bit clunky though.

I think I will just omit the time for now, and hope that Jekyll/Ruby figures out how to deal with time properly - or at least consistently. I think I will be holding my breath for a long time.