Getting store time zone

Hey folks, is there a way to retrieve or access the store timezone through Liquid or JavaScript?

For context

I have some metaobject “date and time” field values

Let’s say the store is on the west coast. Someone in the east coast could get misinformed if I directly used that date and format directly in liquid or javascript right? At least that’s my understanding of it.

Hi @mofahmi

That’s an interesting one.

The concern is that the physical brick and mortar store won’t be open if a customer is visiting from another time zone?

Or are you saying for customer support hours?

Either way, I don’t think it’s normal practice to change these times to match the visitor’s own timezone. If you want to add some more clarity, perhaps consider adding the store’s time zone in the description in the page?

Yeah, it’s specifically for support hours. So for example if you’re saying

We’re closed. Opening tomorrow at 11 am.

The customer would be asking “11 your time or mine?

Another scenario is when doing calculations using JS check if the store status should be Open or closed like this design I’m trying to impliment here

I found myself getting some very weird values subtracting now/today from the field values returned from the metaobject itself, long chat with GPT uncovered that it’s a timezone issue, hence the post

Sorry for the long expo, hope the context is clearer now

Would the ianaTimezone field on the shop object work for this?

Oh nice, thanks @Liam-Shopify , I didn’t know about that one.

That combined with the Intl.DateTimeFormat
formatter should be enough to display the time in the customer’s own timezone:

  const formatter = new Intl.DateTimeFormat('en-US', {
    timeZone: shop.ianaTimeZone,
    timeZoneName: 'longOffset',
  });

  formatter.format(supportStartHour)

Just for completion a way to get the timezone using liquid would be:

{{ "now" | date: "%:z" }}

which would result in an output with the format -03:00

Source: Liquid filters: date

1 Like