如何正确格式化xml站点地图的上次修改(lastmod)时间 [英] How to properly format last modified (lastmod) time for xml sitemaps

查看:104
本文介绍了如何正确格式化xml站点地图的上次修改(lastmod)时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,它会在每次向网站添加或更新新内容时自动更新 sitemap.xml.

I am creating an app that will automatically update sitemap.xml each time new content is added to, or updated on the site.

根据 Google 的最佳实践,<lastmod></lastmod> 标签的格式应如下:

According to Google's best practices the <lastmod></lastmod> tag should be formatted as follows:

2011-06-27T19:34:00+01:00

我的问题涉及时间格式本身.我理解 2011-06-27T19:34:00 部分.我不明白的是 +01:00,我假设它是 +/- UTC.

My question concerns the time formatting itself. I understand the 2011-06-27T19:34:00 part. What I do not understand is the +01:00, which I am assuming is the +/- UTC.

这是一个正确的假设吗?

我的时区表如下所示:

因此,如果该站点位于 #4 阿富汗,则正确的时间是:2011-06-27T19:34:00+04:00

So if the site was based in #4 Afghanistan the correct time would be: 2011-06-27T19:34:00+04:00

如果该站点位于 #6 阿拉斯加标准时间,则正确时间为:2011-06-27T19:34:00-09:00

And if the site was based in #6 Alaska Standard Time the correct time would be: 2011-06-27T19:34:00-09:00

我的假设正确还是我没有正确理解+01:00?

Is my assumption correct or am I not correctly understanding the +01:00?

推荐答案

lastmod 标签在站点地图中是可选的,在大多数情况下它会被搜索引擎忽略,因为网站管理员的工作很糟糕保持准确.在任何情况下,您都可以使用它,格式取决于您的能力和要求;如果您不能或不想,您实际上不必提供时区偏移量,您也可以选择使用简单的 YYYY-MM-DD.

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.

来自 sitemaps.org 的 Lastmod 定义部分:

上次修改文件的日期.此日期应采用 W3C 日期时间 格式.如果需要,此格式允许您省略时间部分,并使用 YYYY-MM-DD.

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.

如果您想进一步了解该粒度并同时提供时区偏移量,那么您是对的,它是 UTC +/-.来自 W3C 日期时间:

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:

时间以本地时间表示,时区偏移量以小时和分钟表示.+hh:mm"的时区偏移表示日期/时间使用本地时区hh";小时和mm"比 UTC 早几分钟.-hh:mm"的时区偏移量表示日期/时间使用本地时区hh";小时和mm"比 UTC 晚几分钟.

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.

例如,仍然来自 W3C:

And example, still from W3C:

1994-11-05T08:15:30-05:00 对应于美国东部标准时间 1994 年 11 月 5 日上午 8:15:30.

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

这篇关于如何正确格式化xml站点地图的上次修改(lastmod)时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆