Koha supports running multiple instances on the same server, even if they need to be homed in different timezones. However, your database must have the timezones installed (see below).
If you are only running one installation of Koha, and want to change the timezone of the server, please do NOT use this feature at all, and instead set your system timezone via the OS. If you are running multiple Kohas, all in the same timezone, do the same.
Only use this feature if you are running multiple Kohas on the same server, and they are not in the same timezone.
For the most part, in execution perl will respect the environmental variable TZ, if it is set. This affects calls to localtime() and other similar functions. Remember that the environment will be different for different users, and for cron jobs. See the example below.
We affect the running perl code of Koha with the Apache directive:
SetEnv TZ "US/Central"
This should be added inside the VirtualHost definition for the intended Koha instance. In almost ALL cases, be sure to set it for both INTRANET and OPAC VirtualHosts. Remember this does not affect the command line environment for any terminal sessions, or your cron jobs.
Your MySQL installation must be configured with appropriate time zones. This extends beyond Koha and affects mysql itself. On debian, for example, you can use:
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
See http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html
Current versions of cron in debian allow ENV variables to be set in the lines preceding scheduled commands. They will be exported to the environment of the scheduled job. This is an example for crontab:
TZ="US/Central" # m h dom mon dow command 0 1 * * * /home/liblime/kohaclone/misc/cronjobs/overdue_notices.pl 15 * * * * /home/liblime/kohaclone/misc/cronjobs/process_message_queue.pl */10 * * * * /home/liblime/kohaclone/misc/migration_tools/rebuild_zebra.pl -b -z >/dev/null
Try these on a command line to confirm Context is setting time_zone based on TZ:
perl -MC4::Context -e 'my $dbh=C4::Context->dbh; my $tz_sth=$dbh->prepare(q(SHOW VARIABLES LIKE "time_zone")); $tz_sth->execute(); print "mysql dbh (Context) time_zone : " . $tz_sth->fetchrow, "\n";'
export TZ="US/Central"; # or any TZ other than the current one.
perl -MC4::Context -e 'my $dbh=C4::Context->dbh; my $tz_sth=$dbh->prepare(q(SHOW VARIABLES LIKE "time_zone")); $tz_sth->execute(); print "mysql dbh (Context) time_zone : " . $tz_sth->fetchrow, "\n";'
Then update your VirtualHosts to do, for example:
SetEnv TZ "US/Central"
Reset Apache, then on your intranet check out the debug page:
cgi-bin/koha/admin/env_tz_test.pl
The TZ that Koha has in effect and the TZ from the database should be displayed at the bottom. Hopefully they match what you set.
WARNING: Multiple timezones may or may not work under mod_perl and mod_perl2.
Joe Atzberger atz at liblime.com