Time zone issues - including British Summer Time

26 0 1


I'm having a nightmare using the 'now' | date: '%s' function. I've been tearing my hair out why my site's been behaving weirdly, until I discovered that for some reason Shopify thinks 'now' should be whatever the time is in the EDT zone (or presumably wherever the server hosting my store happens to be), not, as I have set on my Shopify site, UK time.


I can get the timezone's offset and subtract it from whatever random time zone Shopify decides it's working in, like this (at the moment I'm only interested in seeing if it's before or after 2pm on a Thursday in the UK. You wouldn't have thought it's that hard!):

{% assign hour_now = 'now' | date: '%H' %}
{% assign hour_now = hour_now | plus: 0 %}
{% assign zone_offset = 'now' | date: '%z' %} {% assign zone_offset = zone_offset | divided_by: 100 %}
{% assign local_hour = hour_now | minus: zone_offset %}
{{ local_hour }}

...which gives me the hour of where I am. So far so good. But it's now British Summer Time, so everything's shifted forward an hour. Is there a function that can tell me whether or not BST is active right now? A generic "is it daylight saving time" wouldn't work, because it might or might not be daylight saving time in wherever Shopify's server is located and is generating the 'now' time.


Alternatively, could I do the same thing using JavaScript in Shopify? I want the code to go in two places: a banner on the top of the site (to tell people if they've passed the deadline for this week's orders) and also in the confirmation email (to tell them whether to pick up their order THIS Saturday or NEXT Saturday, depending on whether they ordered it before or after the deadline).


In summary, all I want to find is:
Is it before or after 2pm on a Thursday in the UK?


Any help would be greatly appreciated!