Comment 2 for bug 548311

Revision history for this message
Ray Merrill (rmerrill) wrote :

Although a long term fix needs to allow calendar artefacts
(specifically reminders which get triggered by cron) to
reflect local times for each user, this short term patch
will let you adjust the server timezone to reflect a single
timezone for the majority of your users.

* IMPORTANT * Only works for PHP version 5.1 or higher.

------- ADD THE FOLLOWING TO YOUR CONFIG.PHP FILE --------

// which timezone the server should be acting on - must be
from the list of supported timezones
// ... see http://www.php.net/manual/en/timezones.php
// IMPORTANT: only works if your server is using PHP
version 5.1 or greater
$cfg->servertimezone = 'America/New_York';
//$cfg->servertimezone = 'Pacific/Auckland';
//$cfg->servertimezone = 'Europe/London';
//$cfg->servertimezone = 'Asia/Tokyo';

--------- ADD THE FOLLOWING TO INIT.PHP AT AROUND LINE 62 -
AFTER config.php and config-default.php are processed ------

// fix server timezone, if needed (only works for PHP v5.1
or higher)
if (function_exists("date_default_timezone_set") and
function_exists("date_default_timezone_get")) {
    $CFG->defaultservertimezone = date_default_timezone_get();
    $CFG->originalservertimezone = $CFG->defaultservertimezone;
    if (isset($CFG->servertimezone)) {
        try {
            date_default_timezone_set($CFG->servertimezone);
            $CFG->currentservertimezone =
date_default_timezone_get();
        } catch (Exception $e) {
      if ($e instanceof ConfigSanityException) {
          throw $e;
      }
      $errormessage = ob_get_contents();
      if (!$errormessage) {
          $errormessage = $e->getMessage();
      }
      ob_end_clean();
      $errormessage = get_string('servertimezonefailed',
'error') . $errormessage;
      throw new ConfigSanityException($errormessage);
        }
    } else {
        $CFG->currentservertimezone =
date_default_timezone_get();
    }
}