【问题标题】:Sitemap lastmod date in JavascriptJavascript 中的站点地图 lastmod 日期
【发布时间】:2017-09-21 08:19:27
【问题描述】:

我需要在sitemap.xml 中<lastmod></lastmod> 标记中显示的日期格式。我怎样才能做到这一点?

输出如下:

<lastmod>2016-01-21EEST18:01:18+03:00</lastmod>

“EEST”可能是时区偏移量。

我在php中看到了这个问题和答案:

Google Sitemap Date Format

但不知道如何用Javascript实现,

谢谢。

编辑:这个问题不是重复的,因为我需要 JavaScript 中正确的时间格式。

【问题讨论】:

  • 不,它不是重复的,因为我需要知道这个的时间格式..

标签: javascript php html xml sitemap


【解决方案1】:

lastmod 标签使用YYYY-MM-DDThh:mmTZD 格式,其中TZD 是时区偏移量。 W3 date and time format 为您提供了 3 个选项来执行 TZD:(Z 或 +hh:mm 或 -hh:mm)

这意味着在javascript中你可以使用

const date = new Date().toISOString();

它看起来像 2017-11-15T11:18:17.266Z,这对于站点地图 lastmod 是正确的。

【讨论】:

猜你喜欢
  • 2021-10-10
  • 2022-01-06
  • 2012-07-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-14
相关资源
最近更新 更多