[ZBX-24659] Unable to set 24-hour time format with English Created: 2024 Jun 16  Updated: 2024 Sep 29  Resolved: 2024 Jul 19

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 7.0.0
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: Markku Leiniö Assignee: Oleksii Zagorskyi
Resolution: Cannot Reproduce Votes: 4
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Debian 12 (bookworm), Apache


Attachments: PNG File Zabbix_AmPmError.png    

 Description   

Steps to reproduce:

  1. Install en_GB locale, using https://www.zabbix.com/documentation/7.0/en/manual/appendix/install/locales and/or "sudo dpkg-reconfigure locales" + reboot
  2. In User settings set Language to en_GB (also tried setting the default setting to en_GB)
  3. Go to Problems or use Latest data - Graph for any metric

Result:

Timestamps are still 12-hour AM/PM.

Expected:

Timestamps should be 24-hour.



 Comments   
Comment by Markku Leiniö [ 2024 Jun 16 ]

Removing en_US locale didn't help either (it was removed from the list in Zabbix UI though). And "date" command shows correct 24h output as expected.

$ locale -a
C
C.utf8
en_GB.utf8
POSIX

$ localectl
System Locale: LANG=en_GB.UTF-8
               LANGUAGE=en-GB.UTF-8
    VC Keymap: (unset)
   X11 Layout: fi
    X11 Model: pc105

$ date
Sun 16 Jun 12:10:45 EEST 2024 

 

 

Comment by Onlyjob [ 2024 Jun 29 ]

Could it be a problem with vendor packages? I don't have this issue with Zabbix packages from Debian.

 

1) `sudo dpkg-reconfigure locales`, select `en_GB.UTF-8`.

2) `systemctl restart php8.2-fpm.service` (or restart Apache)

3) Select `English (en_GB)` in User Settings --> Profile.

Comment by Markku Leiniö [ 2024 Jul 07 ]

I also tried installing de_DE.UTF-8 (sudo dpkg-reconfigure locales) and selected "German (de_DE)" as the user language: everything is still in English. I believe that means that none of the Zabbix localization works in this setup.

Any ideas what to add/check/modify to get localization working?

$ php -m | grep gettext
gettext

Workaround to get the 24h timestamps back (like in Zabbix 6.0): edit the output definitions in /usr/share/zabbix/include/translateDefines.inc.php and restart the web server.

Comment by Jeroen Hensing [ 2024 Jul 17 ]

Also tried with replacing system locale or changing user profile language, but that did nothing.
Markku's workaround worked perfectly for me. Thanks man!
In all the define lines with TIME in them, replace h: to H: and removing trialing space A.  Example:

  define('DATE_TIME_FORMAT_SECONDS', _('Y-m-d h:i:s A'));

to

  define('DATE_TIME_FORMAT_SECONDS', _('Y-m-d H:i:s'));

after that refreshed  Zabbix in my browser and it was fixed. Maybe have a backup just in case.

 

Comment by Flemming Carentius [ 2024 Jul 19 ]

I tried it but it didn't work unfortunately

Comment by Markku Leiniö [ 2024 Jul 19 ]

Well well, what do you know: today I installed the latest Debian minor upgrades on the server, for example:

Unpacking php8.2-common (8.2.20-1~deb12u1) over (8.2.18-1~deb12u1) ...

And then my Benutzereinstellungen... I mean, user settings changed so that Zabbix UI was in German! Then I could select en_GB, and now the Problems list has 24h timestamps. I also reinstalled en_US (and restarted Apache) and tried it, then I got AM/PM timestamps. Didn't even reboot the system at any point yet.

So now the localization works as expected on this Debian 12 box.

I don't know exactly or for sure what caused that (but at least Zabbix hasn't been updated meanwhile).

I'd still prefer separate date/time localization, as suggested in ZBXNEXT-7614.

Comment by Jeroen Hensing [ 2024 Jul 22 ]

Carentius: Don't forget to change the other TIME lines as well.... here's my lines: -not the full file, so be careful what you replace...

define('DATE_TIME_FORMAT_SECONDS', _('Y-m-d H:i:s'));
define('DATE_TIME_FORMAT', _('Y-m-d H:i'));
define('DATE_TIME_FORMAT_SHORT', _('m-d H:i'));
define('DATE_FORMAT', _('Y-m-d'));
define('DATE_FORMAT_SHORT', _('m-d'));
define('TIME_FORMAT_SECONDS', _('H:i:s'));
define('TIME_FORMAT', _('H:i'));

define('SVG_GRAPH_DATE_TIME_FORMAT_SHORT', _('n-d H:i'));
define('SVG_GRAPH_DATE_FORMAT', _('Y-n-d'));
define('SVG_GRAPH_DATE_FORMAT_SHORT', _('n-d'));

Comment by Flemming Carentius [ 2024 Jul 22 ]

Marduk
of course.... I overlooked that.... Thanks

Comment by Ingvar [ 2024 Jul 29 ]

check file /etc/default/locale
if it contains a line with "LANGUAGE"
you need to delete it and reboot machine.

Comment by Florian Strankowski [ 2024 Aug 06 ]

We're in the process of evaluating Z7 as replacement for our current LTS setup and i can confirm that exact behavior.

We found the solution: While in Zabbix 6, setting the default system locale to de_DE.UTF-8 is enough to change the time format to 24 hours, even if the user keeps en_US as GUI language selected, Zabbix 7 requires the user to select en_GB (or de_DE) as language option inside Zabbix.

Zabbix 6 LTS is working just fine, using the exact same configuration settings (php8.2-fpm, nginx, de_DE-UTF8 with GUI language english). While Zabbix 6 supports 24 hour format, Zabbix 7 does not.

Comment by Santiago [ 2024 Aug 20 ]

Until there is a proper option to select 24h format I will be running these commands every time I update my zabbix server:

sed "s/define('DATE_TIME_FORMAT_SECONDS', _('Y-m-d h:i:s A'));/define('DATE_TIME_FORMAT_SECONDS', _('Y-m-d H:i:s'));/g" -i /usr/share/zabbix/include/translateDefines.inc.php
sed "s/define('DATE_TIME_FORMAT', _('Y-m-d h:i A'));/define('DATE_TIME_FORMAT', _('Y-m-d H:i'));/g" -i /usr/share/zabbix/include/translateDefines.inc.php
sed "s/define('DATE_TIME_FORMAT_SHORT', _('m-d h:i A'));/define('DATE_TIME_FORMAT_SHORT', _('m-d H:i'));/g" -i /usr/share/zabbix/include/translateDefines.inc.php
sed "s/define('SVG_GRAPH_DATE_TIME_FORMAT_SHORT', _('n-d h:i A'));/define('SVG_GRAPH_DATE_TIME_FORMAT_SHORT', _('n-d H:i'));/g" -i /usr/share/zabbix/include/translateDefines.inc.php
sed "s/define('TIME_FORMAT_SECONDS', _('h:i:s A'));/define('TIME_FORMAT_SECONDS', _('H:i:s'));/g" -i /usr/share/zabbix/include/translateDefines.inc.php
sed "s/define('TIME_FORMAT', _('h:i A'));/define('TIME_FORMAT', _('H:i'));/g" -i /usr/share/zabbix/include/translateDefines.inc.php 

Or just

sed "s/h:i A/H:i/g" -i /usr/share/zabbix/include/translateDefines.inc.php 

No restarts required, just refresh the page.

Comment by Markku Leiniö [ 2024 Sep 29 ]

Just wanted to have a note about the fact that I once again tried to add en_GB to another Debian 12 + Zabbix 7 installation, and I have the same problems I originally described here:

no way to actually have en_GB in affect, even with all latest packages, locale installed and present (en_GB works in shell and shows in Zabbix settings), after reboots.

As of this writing, I'm still puzzled.

Update: Now I know the fix for this: /etc/default/locale had a LANGUAGE variable set (in addition to LANG). Commenting out LANGUAGE and rebooting fixes the localization problem in Zabbix. Restarting Apache (or Zabbix server service) does not help for some reason. Let us know if you know better. (And now I also noticed that this exact solution was already mentioned in a comment above, after my previous comment before today.)

Generated at Fri May 16 10:10:26 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.