Solved

Will the shop/update webhook fire for shops when timezone changes?

Louise_Elmose_H
Shopify Partner
78 2 21

Hi,

 

I have a shop that runs in the CET timezone in winter time and CEST in summer time.

Will I be able to use the shop/update webhook to detect the implicit system timezone change, or do I need to handle it in some other way?

Thanks,

-Louise

Accepted Solution (1)

SBD_
Shopify Staff
1829 269 405

This is an accepted solution.

Hey Louise,

 

Nothing will fire unless they manually update the timezone.

Scott | Developer Advocate @ Shopify 

View solution in original post

Replies 9 (9)

SBD_
Shopify Staff
1829 269 405

This is an accepted solution.

Hey Louise,

 

Nothing will fire unless they manually update the timezone.

Scott | Developer Advocate @ Shopify 

Louise_Elmose_H
Shopify Partner
78 2 21

Hi Scotty,

 

Ok, thank you for your answer.

 

-Louise

Louise_Elmose_H
Shopify Partner
78 2 21

...by the way, I see that there's a field timezoneOffsetMinutes on the shop, so I assume that parameter will return different values depending on whether it's summer time or not for e.g. a Danish shop? I.e. I could query that parameter regularly to determine whether it's summer time or not.

SBD_
Shopify Staff
1829 269 405

Hey @Louise_Elmose_H 

 

Can you elaborate on the use case? There might be a simpler way to solve this.

Scott | Developer Advocate @ Shopify 

Louise_Elmose_H
Shopify Partner
78 2 21
Hi Scotty,

I want to format certain dates that are persisted in UTC in the timezone for a given shop, so times are displayed as local times. In Denmark though the timezone I CET in winter time and CEST in summer time. So I need to know what the timezone is the day that I format the time. For this reason I think I need to query the shop to determine whether we are currently in CET or CEST in Denmark.

Thanks,
Louise
SBD_
Shopify Staff
1829 269 405

Thanks for the summary. Are you able to store dates as UTC and then use JavaScript to display them in the user's timezone (assuming this is happening in-browser)?

Scott | Developer Advocate @ Shopify 

Louise_Elmose_H
Shopify Partner
78 2 21

Hi Scotty,

 

I do store dates in UTC and display them in local time via Javascript, but in addition to that I need to e.g. update orders for a specific time period, generate a report for a specific time period etc., and I would like that to be in local time as well, hence my problem.

The business logic of the app is only relevant for Denmark due to accounting rules, so for this reason I know the locale should be Danish.

 

Thanks,

-Louise

SBD_
Shopify Staff
1829 269 405

Ah I see. In that case it might make sense to store the iana_timezone (more info) and using a library to do the math for you.

 

Here's an example using JS and the Moment.js library:

const localTime = moment(1489199400000).tz('Australia/Brisbane')


If you get stuck, let me know the language and I'll look for an example.

 

 

 

Scott | Developer Advocate @ Shopify 

Louise_Elmose_H
Shopify Partner
78 2 21

Ah ok, that's the moment-timezone library then? I've been using moment so far.