0

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

1 Answer 1

2

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']));
Sign up to request clarification or add additional context in comments.

7 Comments

It worked, just fine, but this is how it looks now 2014-04-28T13:41:49+02:00, shouldn't it be 2014-04-28T13:41:49+00:00??
You need to account for timezones
OK, so if my timezone is GMT and server is in London?
I would expect it to be +00:00. Doublecheck to make sure your server is set up with that timezone. echo date('c');
this is what I have 2014-04-28T15:25:14+02:00
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.