How to properly format last modified (lastmod) time for xml sitemaps

The lastmod tag is optional in sitemaps and in most of the cases it’s ignored by search engines, because webmasters are doing a horrible job keeping it accurate. In any case, you may use it, and the format depends on your capabilities and requirements; you don’t actually have to provide a timezone offset if you can’t or don’t want to, you can choose to go with a simple YYYY-MM-DD as well.

From the Lastmod definition section of sitemaps.org:

The date of last modification of the file. This date should be in W3C Datetime format. This format allows you to omit the time portion, if desired, and use YYYY-MM-DD.

If you want to go down to that granularity and provide the timezone offset as well, you’re correct, it’s UTC +/-. From W3C Datetime:

Times are expressed in local time, together with a time zone offset in hours and minutes. A time zone offset of “+hh:mm” indicates that the date/time uses a local time zone which is “hh” hours and “mm” minutes ahead of UTC. A time zone offset of “-hh:mm” indicates that the date/time uses a local time zone which is “hh” hours and “mm” minutes behind UTC.

And example, still from W3C:

1994-11-05T08:15:30-05:00 corresponds to November 5, 1994, 8:15:30 am, US Eastern Standard Time.

Leave a Comment