Liquid - Show current time based on specific time zone

New Member
2 0 0

Hi everyone!

In Shopify I can use the snippet {{ "now" | date: "%H:%M" }} to show the current time in my timezone.

In Liquid I can use the same snippet but with a filter {{ "now" | in_time_zone: "Europe/Copenhagen" | date: "%H:%M" }} to show the time in a specific timezone, no matter where the visitor is located in the world.

But that filter is apparently not supported by Shopify!

Is there any way to show the current time in a specific timezone in Shopify?

I hope it is possible in Liquid, because I am going to use the output in a Liquid if-function.

Basically what I need is the following: {% assign current_hour_cph = CURRENT HOUR IN CPH  %}

Thank you!

Shopify Expert
10360 158 2004

You should look to use JavaScript instead. If you use the Liquid "now" it won't give you current time, but rather the time in which that page was cached. It's possible for a shop to not need a cache clearing for hours so your time will be erratic - and wrong.

It's not so much that it's unsupported, more that the cache works against you.

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.

★ ★
New Member
2 0 0

Hi Jason.

Thank you, that is a great answer!

I'm really not so experienced in combining Liquid and JS.

Can you give me a clue how to do this?