John Magnolia
John Magnolia

Reputation: 16803

Invalid date when submitting Google XML sitemap

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']))

Upvotes: 5

Views: 10807

Answers (2)

dodov
dodov

Reputation: 5844

You could also use the DATE_W3C date format constant, which matches the required format:

gmdate(DATE_W3C, strtotime($row['modified']['value']));

Upvotes: 1

smartin
smartin

Reputation: 3047

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

Upvotes: 14

Related Questions