pascal_22 Posted December 12, 2012 Share Posted December 12, 2012 Hello, I have a question about datetime. In my website, i have member from canada, usa, france, sweden, belgium..... and a lot of other country Until now, i setup my server for the time GMT, so every date was save at the time of GTM, so every message, profile modification date were always save with that date. In my code: i did: $mDate = new DateTime($profile["DerniereVisite"]); if(!isset($_SESSION["uTimeZome"])) $_SESSION["uTimeZome"]="UTC"; if($_SESSION["uTimeZome"]!="UTC")[b]{ [/b] $tz = new DateTimeZone($_SESSION["uTimeZome"]); $mDate->setTimezone($tz);[b]}[/b] $DerniereVisite = formatTExtDate($mDate->format('Y-m-d G:i:s')); so the $_SESSION["uTimeZome"] keep the good time zone for php for this members, depending on with country he or she is So, with all the test i did, my way works. But now, i change my server for a better server with another compagny. Today, i realize that my server has the localsetting, i mean the server has the date and time for Canada(québec). So i realize that there are some date, that are not converted correctly for some user in other country. So i ask to the administrator for the server to change it to GMT! But his answer was, it's not good to change datetime zone for a server...... that my way to do this is probably wrong and i should check my code...... after some discussion, they finish to change de timezone as i asked. But my question, do i use a good way or a bad way? thanks a lot! Pascal Quote Link to comment https://forums.phpfreaks.com/topic/271910-playing-with-datetime-for-different-country/ 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.