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

Solved

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

vy2902
Shopify Partner
26 0 0

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.

Accepted Solution (1)

remy727
Shopify Partner
44 2 26

This is an accepted solution.

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.

Looking for a Shopify App developer? Please contact me at remy.wang727@gmail.com

View solution in original post

Replies 7 (7)

remy727
Shopify Partner
44 2 26

This is an accepted solution.

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.

Looking for a Shopify App developer? Please contact me at remy.wang727@gmail.com
vy2902
Shopify Partner
26 0 0

Thanks for your reply.

DonnaC
Shopify Partner
6 0 1

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

remy727
Shopify Partner
44 2 26

Good news.

localTime field is on unstable version.

You can check the documentation.

Looking for a Shopify App developer? Please contact me at remy.wang727@gmail.com
DonnaC
Shopify Partner
6 0 1

Thank you

adkhamllama
Shopify Partner
27 1 50

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

RobFarmLink
Shopify Partner
43 2 40

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