How to get Current Date in Cart and Checkout Validation Function API

Topic summary

  • Goal: obtain the current date within Shopify Cart and Checkout Validation Functions. Using JavaScript new Date() returns 01/01/1970 and is not supported.

  • Reason: Shopify Functions are deterministic (same input → same output), so they cannot access the system clock; JS Date is unavailable.

  • Update: an unstable API version now includes a localTime field in the input (Shop object) that exposes the store’s local date.

  • Limitation: localTime currently returns only a date string (e.g., “2019-07-16”) without time-of-day. Developers are requesting full dateTime access rather than relying on date-comparison helpers.

  • Open items: no ETA was provided for stable release or for adding time and store time-of-day. A GitHub feature request for current dateTime support is open for upvotes.

  • Status: partial capability available on unstable (date-only); the need for full dateTime remains unresolved.

Summarized with AI on January 9. AI used: gpt-5.

I want to get current date in Cart and Checkout Validation Function API. I’m using this:

new Date()

But it returns 01/01/1970. I tried to use another ways but cannot get current date.
Can somebody explain this?
And how to i get Current Date in Cart and Checkout Validation Function API?

Thank in advance.

JS date won’t work since functions are deterministic.

The Shopify team has some additions in the works to add the date to the input query.

Thanks for your reply.

Do we know if there is a rough ETA for this please, and if the store time be available as well?

Good news.

localTime field is on unstable version.

You can check the documentation.

1 Like

Thank you

Unfortunately, it is still limited to a date without time.

"2019-07-16"

Shopify could add time as well, instead of multiple date time comparison functions in GraphQL

3 Likes

I also need the current dateTime in my function not a comparison. I opened a feature request on GitHub, please upvote it @adkhamllama .

6 Likes