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.
These would both print out the following:
I think it's wiser to use the following parameters:
Because the first method could give a different format (2020-08-30CEST22:28:28+02:00)