最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Sitemap lastmod date in Javascript - Stack Overflow

programmeradmin4浏览0评论

I need to the date format that is shown in <lastmod></lastmod> tags in sitemap.xml. How can I achieve that?

Output like:

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

Where 'EEST' is probably timezone offset.

I have seen this question and the answers in php:

Google Sitemap Date Format

but don't know how to achieve it in Javascript,

Thanks.

EDIT: the question is not duplicate, since I need the correct time format in JavaScript for this.

I need to the date format that is shown in <lastmod></lastmod> tags in sitemap.xml. How can I achieve that?

Output like:

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

Where 'EEST' is probably timezone offset.

I have seen this question and the answers in php:

Google Sitemap Date Format

but don't know how to achieve it in Javascript,

Thanks.

EDIT: the question is not duplicate, since I need the correct time format in JavaScript for this.

Share Improve this question edited Sep 21, 2017 at 8:26 stormec asked Sep 21, 2017 at 8:19 stormecstormec 1891 silver badge11 bronze badges 1
  • No it is not a duplicate, as I need to know the timeformat for this.. – stormec Commented Sep 21, 2017 at 8:25
Add a comment  | 

1 Answer 1

Reset to default 22

The lastmod tag uses YYYY-MM-DDThh:mmTZD format, where TZD is the time zone offset. The W3 date and time format gives you 3 options for how to do the TZD: (Z or +hh:mm or -hh:mm)

This means that in javascript you can just use

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

and it'll look like 2017-11-15T11:18:17.266Z, which is correct for a sitemap lastmod.

发布评论

评论列表(0)

  1. 暂无评论