XML Sitemap Date Format In PHP

3rd April 2009

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

Comments

Permalink
hi, new to the site, thanks.

waypsublisbub (Sat, 02/19/2011 - 01:43)

Permalink
Thanks

guru (Mon, 07/07/2014 - 11:57)

Permalink
Thanks.. you solved my problem

phponwebsites (Tue, 09/09/2014 - 05:08)

Permalink
so simple. I finally find clear one here .. nice contribution

Herman Nz (Fri, 11/14/2014 - 08:51)

Permalink
Brilliant! Simple! Works! Thanks so much

Tadex (Thu, 09/03/2015 - 02:15)

Permalink
thannks for share :) awesome post..

AmliJatt (Mon, 03/21/2016 - 16:36)

Add new comment

The content of this field is kept private and will not be shown publicly.