Wrong date format on some pages on sitemap

#529319
  • Resolved Astrotwins
    Rank Math free

    Hi, we’re having issues with the generated sitemap. Google is not validating the page_sitemap.xml because some lines have incorrect date format.

    We have a cron that updates the dates for a bunch of pages daily, weekly, or monthly. It’s working fine (you can see the correct date on the page’s code and RankMath’s generated schema). But the sitemap is still showing the incorrect format.

    What is weird is that most pages are showing the correct format, except a few of them (the ones updated daily)

    The wrong date format shown is: 2023-02-15 00:00
    And the pages with the correct date format are like this: 2023-02-13 00:00 -05:00

    I don’t know what else to do. The sitemaps are not cached (I added the filter), also I’ve flushed the cached sitemaps following the directives from the forum, the CDN cache, and everything. The cache is not the issue though, because the sitemap is updated to today’s date.

    Any idea of what could be happening?

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Nigel
    Rank Math business

    Hello,

    Thank you for contacting Rank Math for help with sitemap dates not displaying as expected on your website.

    There may have been a time zone setting change on your website or server from GMT minus 5 to GMT. Please check your date settings on your WordPress dashboard under Settings > General on “Timezone”, make sure a city in your time zone is selected and click ‘Save Changes’. Next, flush the Sitemap cache by following this video screencast: https://i.rankmath.com/pipRDp. After that your pages should show the correct time zone.

    Hope that helps. Please let us know if you have questions.

    Hey Nigel, thanks for your response.

    Have you been able to check the sitemap I sent? If so, you could see there that there are 12 pages near the end that aren’t showing the date properly. But the rest of the pages are correct.

    If you visit any of those pages, you’ll see that the generated schema has the correct format date (i.e. 2023-02-16T00:00:02-05:00) but on the sitemap is showing the incorrect format (i.e. 2023-02-16T00:00:02)

    I’ll paste the relevant part of the RankMath generated schema here for your reference:

    {
      "@context": "https://schema.org",
      "@graph": [
        {
          "@type": "Article",
          "datePublished": "2023-02-16T00:00:02-05:00",
          "dateModified": "2023-02-16T00:00:03-05:00",
        },
        {
          "@type": "WebPage",
          "datePublished": "2023-02-16T00:00:02-05:00",
          "dateModified": "2023-02-16T00:00:03-05:00",
        }
      ]
    }

    I’ve checked the timezone like you said, just in case, but it’s correct and I think it’s unrelated.

    Hello,

    In this case, we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.

    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Thank you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    Thank you for sharing the admin access. I see the wrong dates are shown only on the pages which you have added using the rank_math/sitemap/page_content filter. Please use our following Timezone function to add the date in the correct format:

    
    $timezone = new \RankMath\Sitemap\Timezone();
    $daily_updated_date = $timezone->format_date( HoroscopesSchemaHelper::daily_updated_date() );
    $weekly_updated_date = $timezone->format_date( get_weekly_last_updated_date() );
    $monthly_updated_date = $timezone->format_date( get_monthly_last_updated_date() );
    

    After changing the code, if the Sitemap still shows date in wrong format then please add your site’s FTP access in the Sensitive Data Section.

    I hope that helps.

    That made the trick, thanks!

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘Wrong date format on some pages on sitemap’ is closed to new replies.