louis_coetzee Posted March 12, 2012 Share Posted March 12, 2012 Hi Everyone, Please have a look at this, and tell me if its right? I am generating a sitemap for my website dynamically. The date I am providing: 2012-02-24 11:56:09 and this is the output I am getting: 2012-02-24T11:56:09Z now I am not sure of the Z at the end of the returned value. I think I am looking for something similar to this: 2012-03-12T12:00:02+02:00 not to sure what I am doing wrong and where it gets the timezone from, I am guessing from the php config file. any help would be much appreciated. thanks My code: <lastmod><?php echo $time->toAtom($post['Post']['modified']); ?></lastmod> Quote Link to comment https://forums.phpfreaks.com/topic/258726-datetime-to-atom/ Share on other sites More sharing options...
requinix Posted March 12, 2012 Share Posted March 12, 2012 "Z" represents UTC and is valid shorthand for its timezone. As long as the time is correct for UTC (it was converted from the local timezone properly) you're fine and there's nothing wrong. Quote Link to comment https://forums.phpfreaks.com/topic/258726-datetime-to-atom/#findComment-1326343 Share on other sites More sharing options...
louis_coetzee Posted March 12, 2012 Author Share Posted March 12, 2012 @requinix Thanks very much for your reply. Quote Link to comment https://forums.phpfreaks.com/topic/258726-datetime-to-atom/#findComment-1326346 Share on other sites More sharing options...
louis_coetzee Posted March 12, 2012 Author Share Posted March 12, 2012 What should I change my timezone settings in php.ini to to get the following: 2012-03-12T12:00:02+02:00 which is (UTC+02:00) Harare, Pretoria Quote Link to comment https://forums.phpfreaks.com/topic/258726-datetime-to-atom/#findComment-1326353 Share on other sites More sharing options...
requinix Posted March 12, 2012 Share Posted March 12, 2012 Probably nothing. What does echo date("r"); output? If it uses the right timezone then you have to adjust whatever $time->toAtom is. Quote Link to comment https://forums.phpfreaks.com/topic/258726-datetime-to-atom/#findComment-1326359 Share on other sites More sharing options...
louis_coetzee Posted March 12, 2012 Author Share Posted March 12, 2012 This is the output for echo date("r"); Mon, 12 Mar 2012 11:51:08 +0000 Quote Link to comment https://forums.phpfreaks.com/topic/258726-datetime-to-atom/#findComment-1326365 Share on other sites More sharing options...
requinix Posted March 12, 2012 Share Posted March 12, 2012 Huh. How about the timezone for the computer? Quote Link to comment https://forums.phpfreaks.com/topic/258726-datetime-to-atom/#findComment-1326366 Share on other sites More sharing options...
louis_coetzee Posted March 12, 2012 Author Share Posted March 12, 2012 I hope I understand you correctly. but the timezone for my pc is set to: (UTC+02:00) Harare, Pretoria and the php.ini set to UTC Quote Link to comment https://forums.phpfreaks.com/topic/258726-datetime-to-atom/#findComment-1326367 Share on other sites More sharing options...
requinix Posted March 12, 2012 Share Posted March 12, 2012 Then unset it in the php.ini and let it pick up the timezone from the computer. If that doesn't work (or I'm just misunderstanding you) then set date.timezone according to this list (basically, pick whichever city is closest and in the same timezone with the same DST rules). Quote Link to comment https://forums.phpfreaks.com/topic/258726-datetime-to-atom/#findComment-1326369 Share on other sites More sharing options...
louis_coetzee Posted March 12, 2012 Author Share Posted March 12, 2012 cool, did that, now if I echo date("n"); I get: Mon, 12 Mar 2012 15:01:29 +0200 - which is correct. But with the date to atom, it still shows: 2012-03-12T15:03:34Z with the Z at the end. Why is it not showing it with the +02:00 at the end? Thanks for your help so far. Quote Link to comment https://forums.phpfreaks.com/topic/258726-datetime-to-atom/#findComment-1326390 Share on other sites More sharing options...
requinix Posted March 12, 2012 Share Posted March 12, 2012 Probably because the $time->toAtom() function does it that way intentionally. Look at its code. Let me reiterate: there's nothing wrong with what it's doing (provided it's not doing anything wrong). Whether it shows noon UTC or 2pm UTC+2 doesn't really matter. Quote Link to comment https://forums.phpfreaks.com/topic/258726-datetime-to-atom/#findComment-1326544 Share on other sites More sharing options...
louis_coetzee Posted March 12, 2012 Author Share Posted March 12, 2012 Okay, thanks again. Will not worry about it anymore if that is the case. Quote Link to comment https://forums.phpfreaks.com/topic/258726-datetime-to-atom/#findComment-1326546 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.