Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid date when submitting Google XML sitemap

Tags:

php

When validating my XML sitemap, google says:

Invalid date An invalid date was found. Please fix the date or formatting before resubmitting.

I convert the mysql timestamp by:

gmdate('Y-m-d\TH:i:s', strtotime($row['modified']['value']))
like image 530
John Magnolia Avatar asked Nov 03 '11 21:11

John Magnolia


People also ask

What if Sitemap XML is out of date?

Out dated sitemap can't any harm done for your site but it's beneficial that you regularly update your sitemap because Search engine easily crawl your website updates.

Why is Google not reading my sitemap?

“Sitemap could not be read” often mean that Google just hasn't fetched the file. You can reload the page, or try to check the sitemap in the URL Inspection Tool.


1 Answers

The 'lastmod' element has to be of the format YYYY-MM-DD or YYYY-MM-DDThh:mmTZD so use:

gmdate('Y-m-d', strtotime($row['modified']['value']))

or

gmdate('Y-m-d\TH:i:s+00:00', strtotime($row['modified']['value']))

Read more here

like image 164
smartin Avatar answered Sep 28 '22 09:09

smartin