Ad Widget

Collapse

zabbix time one hour ahead on frontend

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Coma
    Member
    • Oct 2016
    • 36

    #1

    zabbix time one hour ahead on frontend

    My new zabbix install has the time one hour ahead on the frontsite.
    the date and time is correct on the server host, and i have put

    php_value date.timezone Europe/Copenhagen

    in /etc/apache2/conf-enabled/zabbix.conf

    i have also chosen the same timezone in the frontsite config panel.

    [CODE]appliance@admzabbix:~$ timedatectl
    Local time: Fri 2020-11-13 11:08:08 CET
    Universal time: Fri 2020-11-13 10:08:08 UTC
    RTC time: Fri 2020-11-13 09:14:26
    Time zone: Europe/Copenhagen (CET, +0100)
    System clock synchronized: no
    NTP service: active
    RTC in local TZ: no
    appliance@admzabbix:~$[



    appliance@admzabbix:~$ ls -l /etc/localtime
    lrwxrwxrwx 1 root root 39 Nov 13 11:05 /etc/localtime -> ../usr/share/zoneinfo/Europe/Copenhagen
    appliance@admzabbix:~$

    /CODE]

    everything in the zabbix frontpage is shown as the localtime ?
  • Coma
    Member
    • Oct 2016
    • 36

    #2
    no one got an idea on why the time is one hour ahead on the frontend?

    Comment

    • tim.mooney
      Senior Member
      • Dec 2012
      • 1427

      #3
      You don't say what version of Zabbix you're using. That's always a useful bit of information to provide, when asking for help.

      Are you using mod_php with Apache httpd, or are you using the preferred PHP-FPM?

      If you create a file named "whatsmytz.php" within the top level of your Zabbix install, and then put this PHP code in that file:

      Code:
      [COLOR=#000000][COLOR=#0000BB]<?php[/COLOR][/COLOR]
      [COLOR=#000000][COLOR=#0000BB]$script_tz [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]date_default_timezone_get[/COLOR][COLOR=#007700]();
      
      if ([/COLOR][COLOR=#0000BB]strcmp[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$script_tz[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]ini_get[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]'date.timezone'[/COLOR][COLOR=#007700]))){
          echo [/COLOR][COLOR=#DD0000]'Script timezone differs from ini-set timezone.'[/COLOR][COLOR=#007700];
      } else {
          echo [/COLOR][COLOR=#DD0000]'Script timezone and ini-set timezone match.'[/COLOR][COLOR=#007700];
      }[/COLOR]
      [COLOR=#0000BB]?>[/COLOR][/COLOR]
      (it's from the PHP manual for date_default_timezone_get(), https://www.php.net/manual/en/functi...mezone-set.php ) and then visit it with a browser, what does it ouput? The expected timezone?
      Last edited by tim.mooney; 18-11-2020, 07:41. Reason: I cut too much of the PHP into, fixed it so it should work now.

      Comment

      • Coma
        Member
        • Oct 2016
        • 36

        #4
        Sorry its zabbix 5.2

        the output is

        Script timezone differs from ini-set timezone.

        i think i am using mod_php im a little unsure, as it just made a clean ubuntu install and did the apt-get zabbix-server.. and then restores my database to it.

        i did change
        /etc/zabbix/apache.conf

        and added
        php_value date.timezone Europe/Copenhagen

        to it.

        im running zabbix 5.2

        Comment

        • Atsushi
          Senior Member
          • Aug 2013
          • 2028

          #5
          With Zabbix 5.2, you can change the time zone setting for each user. Check the user profile settings.

          Comment

          • Coma
            Member
            • Oct 2016
            • 36

            #6
            Originally posted by Atsushi
            With Zabbix 5.2, you can change the time zone setting for each user. Check the user profile settings.
            yes, that has already been sat as "Europe/Copenhagen" time is still wrong on the frontend.

            Comment

            • tim.mooney
              Senior Member
              • Dec 2012
              • 1427

              #7
              Originally posted by Coma
              Script timezone differs from ini-set timezone.
              I'm sorry, I pasted in the wrong PHP code and didn't notice my error. The code I actually wanted you to run is this:

              Code:
              <?php
              
              if (date_default_timezone_get()) {
              echo 'date_default_timezone_set: ' . date_default_timezone_get() . '<br />';
              }
              
              if (ini_get('date.timezone')) {
              echo 'date.timezone: ' . ini_get('date.timezone');
              }
              
              ?>
              That actually reports what the timezone is set to.

              Originally posted by Coma
              i think i am using mod_php im a little unsure, as it just made a clean ubuntu install and did the apt-get zabbix-server.. and then restores my database to it.

              i did change
              /etc/zabbix/apache.conf

              and added
              php_value date.timezone Europe/Copenhagen
              Ok, it's important to figure that out for certain, because it likely is related to the problem.

              Modern PHP has really shifted away from mod_php, and the Zabbix installation guide too is recommending using PHP-FPM rather than mod_php.

              I hadn't previously looked at the zabbix.conf file from the official packages (my site uses our own custom packages, for various reasons), but can you confirm that the section you edited looks something like this:

              Code:
              <IfModule mod_php5.c>
              php_value max_execution_time 300
              php_value memory_limit 128M
              php_value post_max_size 16M
              php_value upload_max_filesize 2M
              php_value max_input_time 300
              php_value max_input_vars 10000
              php_value always_populate_raw_post_data -1
              # php_value date.timezone Europe/Riga
              </IfModule>
              If that's where you changed the timezone, then there are two problems:
              1. If you're using PHP-FPM instead of mod_php, that entire section is ignored.
              2. Even if you are using mod_php, Zabbix 5.x requires PHP 7.2.25 or later, so I think the section is ignored because it wouldn't be mod_php5.c, it would be mod_php7.c.
              Either way, you need to figure out if you're using mod_php or whether you're using PHP-FPM.

              Comment

              Working...