• Resolved servitel

    (@servitel)


    I have a strange issue. I want to retrieve products under woocommerce using dates_are_gmt. I pass a date and dates_are_gmt=true but this flag is ignored. For example I pass this date “modified_after=2023-04-12T14:39:01″ and woocommerce retrieve products modified before this date. For example retrieve a product with this gmt modified date: date_modified_gmt:”2023-04-12T13:06:43”

    I have also tried with dates_are_gmt=1 with the same result

    Any idea ?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi @servitel

    Thanks for reaching out!

    I understand that you’re experiencing an issue with retrieving products using the dates_are_gmt parameter.

    Based on the information you’ve provided, it seems that the dates_are_gmt flag is not working as expected when you pass the modified_after parameter, correct?

    As a first step, please ensure that you are using the latest versions of WooCommerce and WooCommerce REST API.

    Then, can you please share as well the API request you are using for us to check this further?

    Meanwhile, I will be sharing the techncial documentation about Woo REST API for your reference as well: https://woocommerce.github.io/woocommerce-rest-api-docs/

    Hope this helps!

    Thread Starter servitel

    (@servitel)

    this is the call (I have obfuscated credentials….)

    https://filateliadesimoni.com/wp-json/wc/v3/products/?consumer_key=ck_xxx&consumer_secret=cs_9cxxxx&modified_after=2023-04-12T15:44:01&status=publish&order=asc&per_page=100&dates_are_gmt=true

    One of the products displayed is this one with a gmt date modified BEFORE my requested date

    "date_created":"2018-12-14T17:59:06",

    "date_created_gmt":"2018-12-14T16:59:06","date_modified":"2023-04-12T16:20:10","date_modified_gmt":"2023-04-12T14:20:10"

    Thread Starter servitel

    (@servitel)

    I have tried the filter dates_are_gmt on 5 different woocommerce installations and the result is the same: the dates_are_gmt flag is ignored

    All have the timezome set to Rome. The server time displayed by wordpress is right, the gmt time is right.

    Any idea ?

    Thread Starter servitel

    (@servitel)

    Xue28 is disappeared ??

    Saif

    (@babylon1999)

    Hello @servitel,

    I have a strange issue. I want to retrieve products under woocommerce using dates_are_gmt. I pass a date and dates_are_gmt=true

    From my testing, the filter is working fine, it’s returning only products after a certain time in GMT.


    Link to image: https://d.pr/i/w2KXZn

    You might have a syntax error in one of the parameters which ignore everything after it.

    Have you tried using the modified_after and dates_are_gmt parameters alone?

    If that didn’t help, please attach a screenshot of your WordPress time settings in Settings > General.

    Look forward to hearing back from you.

    Thread Starter servitel

    (@servitel)

    This is the call I made (just obfuscated keys)
    /wp-json/wc/v3/products/?consumer_key=ck_xxx&consumer_secret=cs_xxx&modified_after=2023-04-13T18:35:02&status=publish&order=asc&per_page=100&dates_are_gmt=1

    The first prodct showed hae a modified gmt date 2023-04-13T18:34:32, BEFORE the date I request

    This is the time setup (on all woocommerce I manage):

    Thank for give me an idea on how to fix it !

    Saif

    (@babylon1999)

    /wp-json/wc/v3/products/?consumer_key=ck_xxx&consumer_secret=cs_xxx&modified_after=2023-04-13T18:35:02&status=publish&order=asc&per_page=100&dates_are_gmt=1

    I tried replicating the issue again, this time with your exact same call but the filter was applied with no problem.

    The only objects to which the filter was not applied were the product images, which is expected since the filter is designed for product post types.


    Link to image: https://d.pr/i/baDg5G

    I suggest you try switching the site’s timezone to GMT or any other timezone.

    If that doesn’t help, then please try disabling all plugins except WooCommerce while activating the default Storefront theme.

    If the problem is not present after doing so, then you know there was a plugin conflict. You can enable plugins one by one again to find the culprit.

    Let us know how it goes!

    Thread Starter servitel

    (@servitel)

    On 5 different servers I have followed these steps:

    1. Disabled all plugins and used dates_are_gmt=false. Wrong result as explained on opening post
    2. Changed time zone to UTC+1. Wrong result again
    3. Changed timezone to London. Wrong result

    I have no chances, just write a function at my end to fix this strange issue !

    Saif

    (@babylon1999)

    I have no chances, just write a function at my end to fix this strange issue !

    I understand your frustration at this point. Since you’ve mentioned that the problem is present on multiple WordPress installations, I suggest you report this in the GitHub repository.

    Perhaps the developers there will have better luck replicating the issue. ??

    Cheers!

    Saif

    (@babylon1999)

    Since we haven’t heard from you in a while, we’re hoping that means you were able to get this resolved. I’m going to close this thread now.

    Feel free to open a new topic or reply to this one if you have any other questions.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Dates are gmt don’t work’ is closed to new replies.