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.
Shopify Flow has an improved Send HTTP request action that supports a broader range of integrations with external services by securely storing secrets and returning data to subsequent workflow steps. The action can be securely configured with secrets, such as access tokens or passwords, that are encrypted and obfuscated in Flow. After sending an HTTP request, the full response is returned to the workflow and can be parsed using a Run code action with a JSON.parse method to define a schema so tha…
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