Google Sitemap Date Format

前端 未结 10 1756
情书的邮戳
情书的邮戳 2021-02-12 09:35

I need date format for sitemaps in php.

How can i do that ?

Is this output right ?

2012-08-02EEST18:01:18+03:00
         


        
10条回答
  •  -上瘾入骨i
    2021-02-12 10:29

    To format the current timestamp in W3C Datetime encoding (as used in sitemap.xml files) use the following parameters.

    echo date('Y-m-dTH:i:sP', time());
    

    As of PHP5 you can also use the c format character to print the exact same string.

    echo date('c',time());
    

    These would both print out the following:

    2009-04-03T11:49:00+01:00
    

    SOURCE

提交回复
热议问题