Full DateTime in Checkout Validation Function

shopify/wasm will give unix time of 0 when attempting to get the date

let d = new Date(); // 1970-01-01T00:00:00

So instead, Shopify has a suite of tools to check the date / local time

so, I can check if a time is before, after, or between an expected time … down the the second.

BUT, there is no function to simply pass the full date-time into the function input. the best is:

{shop {localTime {date }}}

Note it is date (not dateTime) From the docs:

Date	
Represents an ISO 8601-encoded date string. For example, September 7, 2019 is represented as "2019-07-16".

I can check the day, but not the hour or second. To check with seconds-level granularity, we have to:

  • use an external api to check the time?!
  • repeatedly check if the time is between some range?!

Solution:
Please add * dateTime * to the graphql schema for the localTime object.

link docs since the forum didn’t allow these on my post, I have to do this

shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql/common-objects/localtime

1 Like

Hey, there are methods on the shop.localTime you can do to check if before/after, would that work?