I need date format for sitemaps in php.
How can i do that ?
Is this output right ?
2012-08-02EEST18:01:18+03:00
>
According to Google, he value is an optional field that, if provided, must be formatted as
YYYY-MM-DDThh:mmTZD
The default export of an SQL datetime is dependent on the language setting for your server, and may include spaces and characterized TZD such as:
2014-09-19 10:33:05 UTC
The W3 specify that TZD can be formatted in any of three options
TZD = time zone designator (Z or +hh:mm or -hh:mm)
Any spaces from your default formatting must be stripped; the character 'T' must be inserted before time, and the TZD must match one of the supported types.
Therefore to format the current timestamp, 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());