Page 1 of 1
MySQL NOW function Minus Four hours (bad server time)
Posted: Fri Aug 22, 2008 7:21 pm
by JAB Creations
My current host (the genius that he is) has the server set four hours ahead of us. I currently use the NOW() function to create a time stamp though it there a reasonably way to adjust the hours so I'm looking at the time from my own time zone? Suggestions for using something other then the now function are welcomed too.
Re: MySQL NOW function Minus Four hours (bad server time)
Posted: Fri Aug 22, 2008 7:41 pm
by it2051229
i'm using oxyhost for my website.. we have the same problem actually.. but the solution that they have provided is in the .HTaccess... if you know how to code on .htaccess, you can set your own time zone there... IF your host allows you
Re: MySQL NOW function Minus Four hours (bad server time)
Posted: Fri Aug 22, 2008 7:55 pm
by JAB Creations
I added this however I don't think it had much if any effect?
Re: MySQL NOW function Minus Four hours (bad server time)
Posted: Sat Aug 23, 2008 8:43 am
by it2051229
well .htaccess can be modified but only works if the host allows it so.. to make things sure you can write email to the host like you know i think they have forums where you can post questions and also ask them how to place the .htaccess code for timezone
Re: MySQL NOW function Minus Four hours (bad server time)
Posted: Sat Aug 23, 2008 9:44 am
by onion2k
.htaccess won't change the value MySQL gets with it's NOW() function will it?
Use "SET time_zone = '+4:00';". You'll need to do it every time you connect to mysql, so your database connection file will likely look something like:
Code: Select all
mysql_connect('localhost', 'username', 'password');
mysql_select_db('mydatabase');
mysql_query("SET time_zone = '+4:00';");
If that doesn't work, try DATE_ADD(NOW(), INTERVAL 4 HOUR) in place of NOW().
Re: MySQL NOW function Minus Four hours (bad server time)
Posted: Sat Aug 23, 2008 12:19 pm
by JAB Creations
That worked! Thanks a ton Onion!
Code: Select all
mysql_query("SET time_zone = '-4:00';");