How to change the time from 12 hours to 24 hours?

OS: Rocky Linux 9
user: root

Guys, I need some very simple help.
I need to change the time zone of Rocky Linux 9 by 24 hours instead of 12 hours. How do I change it to 24 hours?

I tried several commands and nothing worked.

I did some tests but I was unsuccessful.

command:
sudo localectl set-locale LC_TIME=C.utf8

timedatectl status
Local time: Tue 2024-10-22 16:49:03 -03
Universal time: Tue 2024-10-22 19:49:03 UTC
RTC time: Tue 2024-10-22 16:49:03
Time zone: America/Sao_Paulo (-03, -0300)
System clock synchronized: yes
NTP service: active
RTC in local TZ: yes

Are you talking about time format, as displayed? E.g. 18:45 vs 6:45pm

Displayed by whom?

  • GNOME GUI? Settings / Date & Time has Time Format options “24-hour” and “AM / PM”.
  • Terminal, ls? The man ls and info '(coreutils) ls invocation' do mention that format may use info from timezone and or locale. They also mention environment variables TIME_STYLE and LC_TIME.

I managed to solve it, I ran some commands and after a few minutes it went back to normal.

Check:

  • date
  • timedatectl status
  • localectl
  • ls /usr/lib/locale/

Commands:
sudo localectl set-locale LC_TIME=C.utf8

And after a few minutes the time updated to 24 hours, ok!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.