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.
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?