3

I'm getting error "Error: DateTimeZone::__construct: Unknown or bad timezone (7200)" when opening CiviCRM on my Drupal6 site. Refreshing the page clears the error. The error occurred after I upgraded to D6.38 and Civi4.7.11. My timezone is Africa/Johannesburg. Any ideas?

  • * This is not an answer - I don't have the reputation needed to comment @davy-ivins are you also finding that the system status page is broken? I am also getting Timezone errors after updating to 4.7.11 on Drupal 6 and trying to determine if they are the cause of the issue with the system status. Ref: civicrm.stackexchange.com/questions/14848/… – freeform.steph Sep 12 '16 at 20:48
  • I am also seeing the same error message after upgrading from CiviCRM 4.7.9 to 4.7.11, and still persists at 4.7.12 also on Drupal 6.x. Suspecting a defect got into CiviCRM between versions 4.7.9 and 4.7.11. Our error message is as follows: Sorry but we are not able to provide this at the moment. DateTimeZone::__construct(): Unknown or bad timezone (-18000) Also the following shows up in the civicrm log file at the time of the error: Nov 11 16:47:55 [info] $Fatal Error Details = array(3) { ["message"]=> string(61) "DateTimeZone::__construct(): Unknown or bad timezone (-14400)" ["code"]=> NULL [ – Michael Lueck Nov 11 '16 at 22:08
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question. - From Review – petednz - fuzion Jan 11 '17 at 21:12
1

I have a similar setup running Drupal 6 and CiviCRM 4.7.25. My system also showed System Status: Critical and no messages. The issue was is that it first attempts to set the time zone and if that fails it doesn't output any further messages for some reason.

In CiviCRM version 4.7.25 you can use the API console to run the System.check action by visiting http://sitename/civicrm/api#explorer and choosing Entity System and action check to repeat this test while you edit the files.

The fix is to fix the time zone problem which inherits from the Drupal 6 user and sets (in my case) an invalid time zone string which creates this issue.

For instances with Drupal 6, it uses the method CRM_Utils_System_Drupal6::getTimeZoneString() which retrieves the time zone from the user's timezone member in the database, which in my case is the offset in seconds, or a string -14400 for Eastern Time.

The problem is the DateTimeZone code which converts this into a database time zone string supports offsets in hours, not seconds, so I added this code to detect and adjust the values, use at your own risk:

--- Drupal6.php (revision 4843)
+++ Drupal6.php (working copy)
@@ -754,6 +754,9 @@
     // Note that 0 is a valid timezone (GMT) so we use strlen not empty to check.
     if (variable_get('configurable_timezones', 1) && $user->uid && isset($user->timezone) && strlen($user->timezone)) {
       $timezone = $user->timezone;
+     if (is_numeric($timezone) && $timezone % 3600 === 0 && abs($timezone) >= 3600) {
+         $timezone = intval($timezone / 3600);
+     }
     }
     else {
       $timezone = variable_get('date_default_timezone', NULL);

Once I patched this, the check step works correctly and I can review the further messages we're getting. Another trick here, by the way, is to update CRM_Utils_Check::CHECK_TIMER in sites/all/modules/civicrm/CRM/Utils/Check.php to a small number while you're debugging, otherwise the checks update only once a day.

As always, use best practices when working on production systems and back up all source files before modifying them.

The other possible place to look is in the Drupal variables table for the named value date_default_timezone which is used if the user does not have a time zone configured.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.