Rommeo Posted October 4, 2008 Share Posted October 4, 2008 hi i have a hosting that i ll keep many websites. But the problem is date and time is different for these websites. How can i deal with date and time problem by php ? Thanx in advance. Quote Link to comment https://forums.phpfreaks.com/topic/127015-dealing-with-date-and-time/ Share on other sites More sharing options...
ngreenwood6 Posted October 4, 2008 Share Posted October 4, 2008 Make the time your own time. For example if they are 3 hours behind you: <?php $hour = date(g); $minutes = date(i); $seconds = date(s); $my_hour = $hour + 3; echo "$my_hour:$minutes:$seconds"; ?> If that doesnt work for you you can check out [url]www.php.net/date[/url]. I believe there is a way to set the timezone. Quote Link to comment https://forums.phpfreaks.com/topic/127015-dealing-with-date-and-time/#findComment-657032 Share on other sites More sharing options...
Rommeo Posted October 4, 2008 Author Share Posted October 4, 2008 Thank you so much ngreenwood6 I ll use it. Quote Link to comment https://forums.phpfreaks.com/topic/127015-dealing-with-date-and-time/#findComment-657033 Share on other sites More sharing options...
PFMaBiSmAd Posted October 4, 2008 Share Posted October 4, 2008 If you want a php based web site to appear to be in any time zone, just set the default time zone setting to be the time zone you want that site to use for all date/time functions. Ref: http://us.php.net/manual/en/datetime.configuration.php#ini.date.timezone Quote Link to comment https://forums.phpfreaks.com/topic/127015-dealing-with-date-and-time/#findComment-657036 Share on other sites More sharing options...
ngreenwood6 Posted October 4, 2008 Share Posted October 4, 2008 no problem. I dont know if you saw the link or not because I accidently put it into the code poriton but you can set the timezone in the date function. Check out www.php.net/date for more information. Quote Link to comment https://forums.phpfreaks.com/topic/127015-dealing-with-date-and-time/#findComment-657039 Share on other sites More sharing options...
PFMaBiSmAd Posted October 4, 2008 Share Posted October 4, 2008 The date() function uses the current time zone setting and it can display the timezone but you cannot set the timezone in the date function. Quote Link to comment https://forums.phpfreaks.com/topic/127015-dealing-with-date-and-time/#findComment-657047 Share on other sites More sharing options...
Rommeo Posted October 4, 2008 Author Share Posted October 4, 2008 oh i see the difference now. so that means when i use the "now()" function while saving sth in mysql. It will save the wrong date and time wont it ? PFMaBiSmAd ; i think i cant edit the php.ini file. I m a newbie i just bought a hosting plan with cpanel. and i think when i change the php.ini file, Can i change the date and time setting just for a web site ? or will it effect to all my websites ? Quote Link to comment https://forums.phpfreaks.com/topic/127015-dealing-with-date-and-time/#findComment-657050 Share on other sites More sharing options...
PFMaBiSmAd Posted October 4, 2008 Share Posted October 4, 2008 For mysql functions that are dependent on the time zone, you can do the following after you connect to the mysql server (taken from the mysql manual) - Per-connection time zones. Each client that connects has its own time zone setting, given by the session time_zone variable. Initially, the session variable takes its value from the global time_zone variable, but the client can change its own time zone with this statement: mysql> SET time_zone = timezone; To setup any web site, you should be able to put the time zone setting into a local php.ini (when php is running as a CGI application) or in a .htaccess file (when php is running as an Apache module) for each site. Quote Link to comment https://forums.phpfreaks.com/topic/127015-dealing-with-date-and-time/#findComment-657060 Share on other sites More sharing options...
Rommeo Posted October 4, 2008 Author Share Posted October 4, 2008 For mysql functions that are dependent on the time zone, you can do the following after you connect to the mysql server (taken from the mysql manual) - Per-connection time zones. Each client that connects has its own time zone setting, given by the session time_zone variable. Initially, the session variable takes its value from the global time_zone variable, but the client can change its own time zone with this statement: mysql> SET time_zone = timezone; To setup any web site, you should be able to put the time zone setting into a local php.ini (when php is running as a CGI application) or in a .htaccess file (when php is running as an Apache module) for each site. That "timezone" is for what ? a variable like "$timezone = gmt+2" ?? I will be glad if you can explain it. What / where should i write .htaccess ? php file ? Quote Link to comment https://forums.phpfreaks.com/topic/127015-dealing-with-date-and-time/#findComment-657255 Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2008 Share Posted October 5, 2008 The mysql manual, where I found the information in that post, would explain it better than me repleting information in a post. Quote Link to comment https://forums.phpfreaks.com/topic/127015-dealing-with-date-and-time/#findComment-657301 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.