我需要 <lastmod></lastmod>
中显示的日期格式sitemap.xml 中的标签。我怎样才能做到这一点?
输出如下:
<lastmod>2016-01-21EEST18:01:18+03:00</lastmod>
其中“EEST”可能是时区偏移量。
我在 php 中看到了这个问题和答案:
但不知道如何用Javascript实现,
谢谢。
编辑:问题不重复,因为我需要 JavaScript 中的正确时间格式。
最佳答案
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 是正确的。
关于javascript - Javascript 中的站点地图 lastmod 日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46338846/