Tuesday, June 25, 2013

Invalid Date Error in Google Webmaster for Sitemap generated by WordPress SEO by Yoast

If you have recently tested your sitemap that is generated by Yoast plugin for WordPress SEO, then you might have encountered an error in Google Webmaster tools while adding or testing the sitemap.

The error type would usually be mentioned as "invalid date". To fix this, one of the plugin file in Yoast SEO plugin need to be edited. Thanks to a contributor (roaming_elephant) in WordPress support forum, part of the code needs replacement. Here are the step-by-step procedures to fix this problem:

Step 1: open the plugin folder and open this php file: wordpress-seo/inc/class-sitemaps.php

Step 2: Go to line 249 and 250 where you will find the below code:
if ( $query->have_posts() )
 $date = $query->posts[0]->post_modified_gmt;
Replace the above code with the below given code:
if ( $query->have_posts() ) {
  $date = $query->posts[0]->post_modified_gmt;
  $date = date( 'c', strtotime( $date ));
That is all you need to do. You can now go to google webmaster tools and retest your sitemap that is generated by yoast. It should return no errors. If you have any questions, feel free to comment here.


  1. I have been looking for a solution in a while, and I am glad you posted this,however this did not solve the problem. The invalid dates I get are 1969-12-31 16:00 under the following:


    All else is fine, and was already fine. If you know, please let us know. Thanks!

  2. Thanks WP Kid and roaming-elepant,

    I had the same symptoms with Yoast's (ahem) five star SEO plugin. I then discovered this post as the #1 SER on the phrase, "yoast seo invalid date google webmaster." Then I realized...

    I hadn't updated the culprit-site's plugins in a month or so... and this post is dated June 25th. So... I updated the Yoast plugin and... voila, no more webmaster date error.

    Looks like Yoast and co. are listening. Maybe not a perfect five star, but he/they get it.

  3. Nice post........Thank you for sharing such a useful information about SEO with us......It really helped a lot Fake Comment Creator word press plugin

  4. Keep up the great work, its hard to find good ones.
    seo backlinks service

  5. We are really grateful for your blog post. You have done a great job. I will definitely dig it and personally recommend to my friends
    High Trus Flow and Citation Flow backlinks

  6. Looking at ranking 1st in Google? Looking to grow your business? Look no further, we are Engage Online, an SEO Agency from Australia. Our SEO services maximise business marketing, boost traffic to websites, and raise Google Ranking
    SEO Australia

  7. Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject.
    Niche comment

  8. Here are some Pros and Cons of having a DoFollow Blog: paid backlinks

  9. I havent any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us.
    website traffic