How to get current date/time in Shopify Flow?

Hi guys -

I’m trying to create a Date object using new Date() in Shopify Flow, but it seems to return an empty or invalid date (like 1970…).
In Shopify Functions, I was able to get the current time using localTime inside the shop query. But I couldn’t find anything similar in Flow queries.

Does anyone know how to get the current date/time in Shopify Flow? Any workaround or best practice?

If your flow does not have too much delay built inside, you can leverage the {{ scheduledAt }} object, this should be a starting point

The send-http-request action now returns responses.
So use it to hit a time api then try other ways as possible fallbacks.

:rofl: For giggles try making an empty liquid template with {{ “now” | date }} as an endpoint, it can cache/stale though.

Going for even more giggles you could do:

  • An alternate template index.time.json containing the data you need (markup, JSON …)
  • Use the {{ scheduledAt }} object to generate an unique ID (i.e. chaining | md5 filter)
  • Use the send-http-request to crawl the endpoint as follow store.com/?view=time&page=uniqueId
  • The view parameter gives you the custom data you need, the page parameter breaks caching
  • You now have all the fresh time data you need !
1 Like