Google Sitemap Date Format

前端 未结 10 1758
情书的邮戳
情书的邮戳 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条回答
  •  日久生厌
    2021-02-12 10:23

    To convert from a MySQL's datetime format to the one needed for lastmod in sitemaps, just use the PHP code below.

    $lastmod = '2012-11-28 10:53:17'; //MySQL datetime format
    
    $datetime = new DateTime($lastmod);
    $result = $datetime->format('Y-m-d\TH:i:sP');
    
    echo $result; //2012-11-28T10:53:17+01:00
    

提交回复
热议问题