TimeZone Version 8.0

Hi,

I have recently installed SuiteCRM version 8.0, and it is working fine. The problem which I am facing is that, all the records are being saved in UTC timezone, which is having a big issues with my users.

I tried changing the timezone from their user profile, but still, after making the changes in the profile timezone is no affect on the list nor other area of Suite CRM.

Kindly guide how can I get the time corrected.

Thanks in Advance!!!

Hi,

Is there any solution for this?

Hi @amitkumar,

This is hopefully just a wee problem of configuration as its also how Suite7 work.

To allow for users in differing time zones crm data is saved as the “Locale” setting which is found in the admin menu and from there converted to the Time zone selected in User settings.

Ensure you have Locale configured to the main timezone, and then ask the users to ensure there timezone within advanced matches their own. At which point time and dates should be displayed properly.

Any further issues or questions please let me know!

In the Locale, there is no timezone in version 8.0.1, attached is the screenshot.

Hi, in version 8.0.4, the timezone is still stucked in UTC (yes, even when changing the user profile local settings).
Does someone know if this has been fixed in a more recent version ? Or if there’s a plan to fix it soon ?

Thanks !
Louis

Hi @LJTisseur,

Have you tried using the most recent version: 8.1.2?

If not I’d suggest upgrading and giving it a go there. Keep in mind you also have a timezone option in “Locale” within the admin menu. Your timezone may also be defined by the time on the computer hosting the instance of Suite so it may need to be updated there.

If your issues persist let me know!

It is a bug:

i’m facing same issue in 7.14.1. I changed user’s time zone (Asia/Kolkata GMT + 5:30) in user profile advance section. but after user login it is set to again UTC GMT 0

Hi,

I just installed 8.7 and timezone keeps reverting back to UTC GMT 0. This makes the CRM quite useless for serious business use.

Is there a workaround for this or everyone is training their users to live in different places.

Thanks in advance for your help.

Just a clarification for the previous post…

The timezone is set in the user profile. I refresh the screen and I can see it is set. However, when I log out and log back in, it resets to default.

I confirm, timezone turns back to UTC when user logs in. I had to write a hook to force suitecrm to keep my timezone in user profile.

Have you checked your timezone in php.ini too?

Bu the way, I confirm that the timezone is only kept in the session and not saved into the DB. When I change it and refresh the page, it looks like it was saved. But when I open an incognito page and login there, timezone is not set. When I comeback to the normal window and refresh the page it is still set correctly.

So, it is not the login/logout resetting it, it just does not save it. Everything else on the user profile page is saved.

Hi adam_2,

I am trying to write a hook as well but i cannot get it invoked under 8.7. I am new to this and I tried to use ChatGPT in instruct me but the folder structures are different under 8.7. Here is what ChatGPT tells me the below. In 8.7 custom folder is under public/legacy/custom.

Steps to Create a Logic Hook

  1. Define the Logic Hook:
  • Edit the custom/modules/Users/logic_hooks.php file (create it if it doesn’t exist):

php

<?php
$hook_array['after_login'][] = [
    1,
    'Set Timezone on Login',
    'custom/modules/Users/SetTimezoneOnLogin.php',
    'SetTimezoneOnLogin',
    'setTimezone',
];
  1. Create the Logic Hook Class:
  • Create the file custom/modules/Users/SetTimezoneOnLogin.php:

php

<?php
if (!defined('sugarEntry') || !sugarEntry) {
    die('Not A Valid Entry Point');
}

class SetTimezoneOnLogin
{
    public function setTimezone($bean, $event, $arguments)
    {
        // Set the desired timezone (e.g., 'America/New_York')
        $timezone = 'America/New_York';

        // Update the user's timezone preference
        $bean->setPreference('timezone', $timezone);
        $bean->savePreferencesToDB();
    }
}
  • Replace 'America/New_York' with your desired timezone.
  1. Run a Quick Repair and Rebuild:
  • Go to Admin > Repair > Quick Repair and Rebuild to ensure the logic hook is recognized.

In my case, php.ini is fine. It is set to my timezone.

I managed to invoke the set timezone after login but even though it sets it (I confirm and print it by getting it), it still loses the timezone somewhere after the login is completed.


BECAUSE I AM NEW USR, IT WON’T LET ME ADD THIS TO THE THREAD. SO I AM EDITING MY OWN REPLY.

I found the bug and fixed it. In User.php line 869, it did not check whether the timezone was already set before setting it to default UTC in the case of no POST. I added the elseif section below.

        if (isset($_POST['timezone'])) {
            $this->setPreference('timezone', $_POST['timezone'], 0, 'global');
        } elseif (!$this->getPreference('timezone', 'global')) {
            $this->setPreference('timezone', 'UTC', 0, 'global');
        }

Have any of you tried 8.7.1?

I think the bug with session preferences not being saved is fixed in that version.

In 8.7.1 timezone bug still exists.

My working hook looks like this:

// 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'); 
// 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');
    }
}

Quick Repair and Rebuild

1 Like

Nope! The bug is still there! :frowning: I recently installed 8.7.1 from scratch and the timezone is still resetting to UTC.

If you can find the corresponding issue on GitHub and post your findings there, it would be useful.

Thank you Adam, your solution worked perfectly :slight_smile: