Problems with MySQL and timezones


#1

I’m having a lot of trouble getting my timezone to work properly in MySQL. I’ve tried doing a:
set time_zone = 'Australia/Sydney’
from mysql and I get the message:
ERROR 1298 (HY000): Uknown or incorrect time zone: Australia/Sydney
I know this time zone is correct because I’m using it in linux & php (ie. export TZ=‘Australia/Sydney’), and I’ve tried using other timezone names and get the same message.
Anyone know why this isn’t working?


#2

Take a look at this thread to see how to do it with .htaccess:
http://discussion.dreamhost.com/showthreaded.pl?Cat=&Board=forum_programming&Number=29520

Or you can try the following PHP code:

putenv('TZ= Australia/Sydney'); //format the timezone for SQL $timeZone = preg_replace('/([+-]\d{2})(\d{2})/', '\'\1:\2\'', date('O')); mysql_query('SET time_zone='.$timeZone); (from http://uk.php.net/manual/en/function.putenv.php)

hope that helps