向google提交sitemap.xml总是报时间错误解决

向google提交sitemap.xml总是报时间错误解决

xml 提交到 google search console 后总是提示:

1
2
日期无效
发现无效日期。请修正日期或格式,然后重新提交。 父标记:url

xml 原文:

1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" encoding="utf-8"?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>http://www.test.com/test.html</loc>
<priority>0.80</priority>
<lastmod>2020-04-28 00:00:00</lastmod>
<changefreq>daily</changefreq>
</url>
</urlset>

lastmod 时间需要转换一下,不能直接使用事件对象,需要使用

1
2
new Date().toISOString()  
// "2020-12-30T01:08:56.543Z"
作者

Terwer

发布于

2022-07-03

更新于

2022-07-03

许可协议

评论