Time Zone resets itself to UTC in Version 8.7.1

SuiteCRM 8.7.0 and 8.7.1 contains a bug that resets timezone to UTC on user login.

If all your users can have the same timezone you can create a hook to fix this issue:

// FILE: // /var/www/public/legacy/custom/Extension/modules/Users/TimezoneQuickFix.php
class TimezoneQuickFix
{
    const FORCED_TIMEZONE = 'Europe/Vatican';
    
    function fix($bean, $event, $arguments)
    {
        global $current_user;

        if ('UserPreference' != $bean->object_name ?? ''){
            return;
        }
        if (self::FORCED_TIMEZONE == $current_user->getPreference('timezone')){
            return;
        }
        $current_user->setPreference('timezone', self::FORCED_TIMEZONE, 0, 'global');
    }
}

AND

// FILE: /var/www/public/legacy/custom/Extension/application/Ext/LogicHooks/TimezoneQuickFix_Hook.php
$hook_array['after_save'][] = Array(1, 'Fix timezone returning to UTC', 'custom/Extension/modules/Users/TimezoneQuickFix.php','TimezoneQuickFix', 'fix'); 

Quick Repair and Rebuild

3 Likes