EKsumic's Blog

let today = new Beginning();

Click the left button to use the catalog.

OR

使用Simple Mvc Sitemap产生的Sitemap的lastmod里面的日期格式错误

使用Simple Mvc Sitemap产生的Sitemap的lastmod里面的日期格式错误,Google无法读取这样的Sitemap

Google Console 提交Sitemap出错,日期无效:

报错:
发现无效日期。请修正日期或格式,然后重新提交。

详细信息:
父标记:url
标记:lastmod

根据《国际标准ISO 8601》 

  • 2020-4-20(×)
  • 2020-04-2(×)
  • 2020-4-2(×)
  • 2020-04-20(√)

日期格式标准应该是2020-04-20的表示方法。

Google可以另外接受这样的日期格式:

<lastmod>2020-07-01T13:24:31+09:00</lastmod>

 

解决方案:

public DateTime GetCorrectDate(DateTime dateTime)
{
    DateTime lta = dateTime;
    DateTime w3cDateTime = new DateTime(lta.Year, lta.Month, lta.Day, lta.Hour, lta.Minute, lta.Second, DateTimeKind.Local);
    return w3cDateTime;
}

使用方式:

List<SitemapNode> nodes = new List<SitemapNode>
{
    new SitemapNode(Url.Action("Index", "Home"))
    {
        ChangeFrequency = ChangeFrequency.Daily,
        LastModificationDate =GetCorrectDate(DateTime.UtcNow),               
        Priority =1.0M
    },          
};

参考文档:

https://github.com/uhaciogullari/SimpleMvcSitemap/issues/16

This article was last edited at 2023-11-13 14:40:03

play slots online

You are so interesting! I don't believe I've read through something like this before. So great to find another person with unique thoughts on this topic. Seriously.. thanks for starting this up. This website is something that is needed on the internet, someone with a little originality!

reply

2024-07-14 08:32:59

LINE TOGEL

Thank you for every other informative blog. Where else could I am getting that type of info written in such an ideal manner? I've a challesnge that I aam just now operating on, and I have been at tthe look out for such information.

reply

2024-09-02 06:06:30

Pummy

Hello there! Do you use Twitter? I'd like to follow you if that would be ok. I'm definitely enjoying your blog and look forward to new updates.

reply

2024-09-03 11:43:53

Lumina Grand Showflat

Yes! Finally someone writes about Lumina Grand.

reply

2024-09-15 21:14:58

Securityzxd

"Julia's Garland" (fr. Guirlande de Julie)

reply

2024-09-18 19:34:51

프리서버

요즘 프리서버의 플랫폼 자회죽은 원인 게임빌컴투스플랫폼은 근래에 자체 게임 서비스 플랫폼으로 구축했던 하이브를 외부 게임사에 개방하였다. 하이

reply

2024-10-22 15:05:47

Today's comments have reached the limit. If you want to comment, please wait until tomorrow (UTC-Time).

There is 16h44m16s left until you can comment.