Question

I am trying to format last modified timestamp for all pages, but need to get it in specific format.

This is how it should look: 2014-04-26T15:58:45+00:00, but all my attempts are either ended with error or just like that 2014-04-28 13:41:49

here is my variable date($info['sitemap_last_modified']);

I was also trying to use the following date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000));, but I do not know where to place the following $info['sitemap_last_modified']

Please help me

Was it helpful?

Solution

Just use the c modifier for the PHP date() function.

// Assuming $info['sitemap_last_modified'] is in a 
// standard format strtotime() can parse
// http://www.php.net/manual/en/datetime.formats.php
echo date('c', strtotime($info['sitemap_last_modified']));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top