• Resolved shimist

    (@shimist)


    I use the lunar calendar and Google records this error
    How can I show the editing and publishing date for Google?

    How to edit these codes to show the date in the Google structured data testing tool

    1441/10/01 23:30:02 (Cannot understand the value 1399/2/31 23:30:02 as a date/time. Learn more about

    $_date_published = $this->snippet->item->date_published();
    if ($_date_published) {
    $this->build[‘root’][‘items’][‘published’] = array(‘tag’ => ‘meta’, ‘itemprop’ => ‘datePublished’, ‘content’ => $_date_published);
    }

    $_date_modified = $this->snippet->item->date_modified();
    if ($_date_modified && $_date_published != $_date_modified) {
    $this->build[‘root’][‘items’][‘modified’] = array(‘tag’ => ‘meta’, ‘itemprop’ => ‘dateModified’, ‘content’ => $_date_modified);
    }
    }
    }

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Milan Petrovic

    (@gdragon)

    The plugin uses post/page publish modified date supplied by WordPress using the format required by Google for the snippet. Based on the year value 1441, it is based on the Islamic calendar, I assume? Is the year in the post stored as 1441 or 2019, I am not sure how Islamic dates are stored in WordPress or database and how they are handled for display purposes?

    Thread Starter shimist

    (@shimist)

    Date in Posts as 1441
    Is there no way to solve this problem?

    Plugin Author Milan Petrovic

    (@gdragon)

    Google expects current dates, and dates too far in the past are most likely considered invalid. The date format Google requires doesn’t have any way to specify the calendar used for the date, so they always parse date as the standard Gregorian calendar.

    Right now, I don’t know how to solve this.

    Actually the date on the OP’s (the person who started this thread) post is “1399/2/31” (Error says: cannot understand the value 1399/2/31 23:30:02 as a date/time.) which at least is a valid and current date in the country that I live in (We use Jalali date).

    So the thing is as @gdragon mentioned, Google only expects Gregorian Calendar.

    We use conversion plugins on our websites to change the dates in WordPress.
    For example these to plugins :
    https://wordpress.org/plugins/wp-parsidate/
    https://wordpress.org/plugins/wp-persian/

    I don’t know how but someway Yoast SEO always manages to output the gregorian date in their schema information on posts, even when the date on the post is Shamsi/Jalali.

    It’d be awesome if you found a way to only output the Gregorian date in GD Rating System too. Because at least in Article schema type this is actually causing issues in Google Search Console.

    Plugin Author Milan Petrovic

    (@gdragon)

    One way is to hook into the snippet generator, take the prepared array before it is printed, and convert the dates before they are processed. It is not very elegant, but, as far as I know, there is no way in WordPress to specify calendar used with the date, and in theory, you can have posts with both calendars in the same time, making the conversion before a guessing game (or checking if the year is far into the past), again not very elegant.

    If the whole website is using a different calendar, then, it would be easier, all dates need to be converted. If you have suggestions on how to solve this in the GD Rating System plugin, let me know.

    What I say may sound weird and funny but bear with me since I am not in any way an expert neither in programming nor in WP.

    So I looked through the Yoast SEO Plugin source and I found to output published and modified date in schema markup they use this line of code :

    $post->post_date_gmt
    $post->post_modified_gmt

    and then I looked through the WordPress DB and in wp_posts table I saw “post_date_gmt” and post_modified_gmt columns which contain the valid Gregorian publish and modified dates in GMT time.

    So I don’t exactly know how but maybe you can access this directly?

    • This reply was modified 5 years, 12 months ago by metalsoft.
    Plugin Author Milan Petrovic

    (@gdragon)

    So, columns with GMT datetime are storing dates in the Gregorian calendar as it looks, it is not just GMT time, but the date is Gregorian. I can work with that and use GMT values instead. I can include option in settings to choose what to use. Thanks! I will implement this in one of the future versions.

    Thank you. It’d be awesome 🙂

    Plugin Author Milan Petrovic

    (@gdragon)

    This is not working. I tested, and GMT date/time is same as normal date/time but with time zone correction. I set the date to the year 1399, and both normal and GMT values are same year. I then tested Yoast SEO, and it also displayed 1399 in their snippet and there is nothing in Yoast plugin to convert non-Gregorian dates.

    In any case, I will have a GMT option in the next update, but, it looks like that some additional software is need to either store or convert dates to different calendars, and Yoast SEO doesn’t do it on its own.

    Hmmm, Why do you set the year to 1399? I think what you need to do is output the date exactly as is provided in the DB by WordPress. Because showing the date as 1399 is exactly what we are trying to avoid here.
    For me, on my posts, what Yoast SEO shows in the OpenGraph data and Schemas are both Gregorian dates.

    • This reply was modified 5 years, 12 months ago by metalsoft.
    • This reply was modified 5 years, 12 months ago by metalsoft.
    Plugin Author Milan Petrovic

    (@gdragon)

    Well, the only way for this to work properly is to use GMT dates and have some plugin that will implement Islamic calendar, without it, years don’t get converted. Anyway, I will implement similar method to get date as Yoast SEO does, so it should work the same way.

    Plugin Author Milan Petrovic

    (@gdragon)

    Version 3.1 now has the option to use GMT datetime fields.

    Thank you

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Cannot understand the value date/time’ is closed to new replies.