How to use dateTimeAfter/dateTimeBefore correctly?

Topic summary

A developer is experiencing issues with Shopify’s dateTimeBefore function not behaving as expected according to documentation.

The Problem:

  • The function should return true if the current date/time is before a given date/time, and false otherwise
  • When testing with different times (one at start of day, one at end of day), both return the same value (true), suggesting the validation isn’t working correctly

Use Case:

  • Attempting to validate expiration times stored in Metafields
  • Needs to compare current time against a stored expiration timestamp
  • Considering using this function for cart and checkout validation

Status: The issue remains unresolved with no responses yet. The developer is seeking help to understand if this function can properly handle their expiration time comparison needs.

Summarized with AI on November 5. AI used: claude-sonnet-4-5-20250929.

According to docs, dateTimeBefore will return true if the current date and time is before the given date and time, and false otherwise.

but when I try to use other time in my input query for the cart and checkout validation function, one is the start of the day, and one is the end of the day but it returns the same value is true

  shop {
    localTime {
      dateTimeBefore(dateTime: "2024-09-30T23:24:31")
    }
  }

I’m trying to validate the expiration time that I set in Metafield, because we cannot get the current time in function to compare, so I considered using this. Can it help for this case?