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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With