Set the Linux clock display to 24-hour format

How to switch Linux to 24-hour time in the desktop clock, the terminal locale, and individual commands. Covers what each method changes, its side effects, and how to keep copied timestamps usable.

Linux stores the current time internally as a count of seconds in UTC. Whether you see 14:30 or 2:30 PM depends on how that value is presented, and three different layers can decide that: the desktop clock, the locale, and the format string in an individual command. Switching to 24-hour format changes only the presentation. Which layer you change determines where the new format appears and what else changes with it.

Is 24-hour display the right choice?

For most people who want 24-hour time, the best starting point is the desktop clock setting. It changes the panel clock and nothing else. The main benefit of 24-hour notation is that a time is unambiguous without an AM/PM marker, sorts correctly as text, and matches the format most system logs already use. The main tradeoff appears when you change the locale instead of a single clock setting. A locale controls date order, month and weekday names, and other conventions as well as the clock, so one change can affect many applications.

Keep the default 12-hour presentation if the people you share times with expect AM/PM, or if existing scripts read locale-formatted output and you cannot update them. In those cases, add 24-hour time only where you need it, such as in your own prompt or in specific commands.

What the setting actually changes

None of the methods below changes the system clock, the hardware clock, the time zone, or file timestamps. Each one only controls how a stored time is turned into readable text. This is not a character transformation either: no glyphs are substituted or reordered. The output is ordinary digits and colons.

Layer | What it affects | Scope | Main side effect
Desktop clock setting | The panel or top-bar clock, and in some desktops related shell components | Your user session on that desktop | Minimal; usually limited to the clock
Locale (LC_TIME) | Default time and date output of commands and applications that follow the locale | Per user or system-wide | Also changes date order, names and other time conventions
Explicit format string | One command, prompt or script | Only where you write it | None beyond that output

Desktop panel clock

GNOME provides a 24-hour option in Settings under Date & Time. You can also set it from a terminal:

gsettings set org.gnome.desktop.interface clock-format '24h'

Cinnamon uses its own key:

gsettings set org.cinnamon.desktop.interface clock-use-24h true

In KDE Plasma, the Digital Clock widget's settings include a time display option, and the Region & Language settings define the default time format. Option labels differ between Plasma releases. In Xfce, open the Clock plugin's properties and choose a 24-hour layout, or enter a custom format such as %H:%M. The exact menu paths on your system may differ from these descriptions, so check them against your desktop version.

Terminal and applications: the LC_TIME locale

Many command-line tools and applications choose their default time format from the LC_TIME locale category. With an en_US locale, recent versions of the date command print 12-hour time with AM/PM. To see the current settings, run:

locale
locale -a

The first command shows the active locale values. The second lists the locales installed on the system. If LC_ALL is set, it overrides LC_TIME, so clear LC_ALL before relying on LC_TIME. On systemd-based distributions, you can set the time category system-wide while leaving the rest of the locale unchanged:

sudo localectl set-locale LANG=en_US.UTF-8 LC_TIME=C.UTF-8

Include your existing LANG value in this command so it is preserved. The C.UTF-8 locale uses 24-hour time and keeps English names and month-before-day date order. That makes it a smaller change for US readers than switching to en_GB.UTF-8, which also uses 24-hour time but places the day before the month. Check that the locale you choose appears in the output of locale -a. If it does not, generate it first; the method depends on your distribution. New sessions pick up the change after you log out and back in. To make a per-user change instead, export LC_TIME in your shell startup file.

Single commands and the shell prompt

An explicit format string applies only where you write it and does not depend on the locale. With GNU date, %H is the 24-hour hour, %I is the 12-hour hour, and %p is the AM/PM marker:

date +%H:%M
date +%Y-%m-%dT%H:%M:%S%z
date -Iseconds

In a Bash prompt, \A shows 24-hour HH:MM and \t shows 24-hour HH:MM:SS. By contrast, \T and @ show 12-hour time. For GNU ls, you can set the time style directly:

PS1='[\A] \u@\h:\w\$ '
ls -l --time-style='+%Y-%m-%d %H:%M'

Will the result stay usable after copying or sharing?

A 24-hour time is plain ASCII text, so copying and pasting does not introduce special or invisible characters, and editing and search work as they do for any other text. The practical risks come from context, not from the characters themselves:

  • Scripts that parse locale-dependent output, such as the default output of date or ls -l, may break after an LC_TIME change. Scripts should use an explicit format string, or set LC_ALL=C for the command whose output they parse.
  • A bare time such as 14:30 does not include a time zone. For logs, tickets or messages to people in other places, use ISO 8601 with an offset, such as the output of date -Iseconds.
  • Some recipients, particularly in the US, read 12-hour time more comfortably. When sharing with them, a plain-text 12-hour equivalent may be clearer.

Accessibility could not be verified. No documentation or test results were available showing how specific screen readers announce 24-hour times on Linux desktops. If you rely on assistive technology, check how it reads the clock after you change the setting.

Limits of this review

The commands and settings above describe the general documented behavior of common Linux components: GNOME, Cinnamon, KDE Plasma, Xfce, glibc locales, GNU coreutils and Bash. They were not tested on a particular distribution or release for this article. Menu labels, available locales and default output can differ between versions, so confirm the result on your own system.