By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

Invalid date in lastmod on Google webmaster tools

How to debug invalid lastmod date in Google webmaster tools

Edited: 2013-12-26 16:39

This is what you can do if you submitted a sitemap to Google, and everything appears to be valid, but you still get the invalid date in lastmod error.

This problem is usually coursed by an invalid date, either due to a invalid or missing time stamp in the database, or due to a problem with the code that generates the sitemap.

Debugging invalid date

What you can do:

  1. If possible, look up the line number.
  2. Make sure that a valid date format is used.

You can easily output a valid date with the PHP date function, the following examples will both work. The first is the YYYY-mm-dd format, which doesn't include the hour and minute, the latter will generate a ISO 8601 date.

$formatted_date = date('Y-m-d', $row['last_updated']); // YYYY-mm-dd

$formatted_date = date('c', $row['last_updated']); // ISO 8601 (added in PHP 5)

The ISO 8601 date will look like the below: