I am in a learning phase. I could not find the command to change my time format from 12 hour to 24 hour. Can anyone please help me with this? Thank you!!
-
1Do you want to get the time or set the time from terminal? – heemayl Jul 04 '16 at 11:29
-
Hi Abhishek. Could you give some feedback on the answers? Was it what you were looking for? please mention. – Jacob Vlijm Jul 05 '16 at 12:15
4 Answers
Time settings, as as shown in the panel, are set with gsettings
. You can set 12/24 hrs by the commands:
12-hour:
gsettings set com.canonical.indicator.datetime time-format 12-hour
24-hour:
gsettings set com.canonical.indicator.datetime time-format 24-hour
options are:
locale-default
12-hour
24-hour
custom
The same trick on Mate
...requires a different command:
12-hour:
dconf write /org/mate/panel/objects/clock/prefs/format "'12-hour'"
and, as one would expect, 24-hour:
dconf write /org/mate/panel/objects/clock/prefs/format "'24-hour'"
N.B. tested on Mate 16.04 by @Zana (thanks!)

- 83,767
-
I like this answer a lot (I upvoted it also) but in MATE I get 'no such schema' :( and in fact
gsettings list-recursively | grep time-format
returns nothing at all. I wonder how I can do it... – Zanna Jul 04 '16 at 13:36 -
@Zanna, what version of Mate do you run? I found two settings that should work if settings made sense, but they don't change a thing on my VM:
gsettings set org.gnome.desktop.interface clock-format 12h
anddconf write /org/mate/panel/objects/clock/prefs/format "'12-hour'"
. (Mate 15.10) – Jacob Vlijm Jul 04 '16 at 15:57 -
First one does nothing for me either (even on reboot), but
dconf write /org/mate/panel/objects/clock/prefs/format "'12-hour"'
works instantly (I undid it - I hate 12 hr clock haha) – Zanna Jul 04 '16 at 19:14 -
@Zanna Greatgreat! thanks for testing, will add it to the answer :) – Jacob Vlijm Jul 04 '16 at 19:15
-
^^ my pleasure. Now trying the same in Xubuntu...
dconf write /org/gnome/desktop/interface/clock-format "'12-hour'"
should do it, but doesn't >< I'll come back if I fix it – Zanna Jul 04 '16 at 19:36 -
1Correct me if I am wrong but I tried
"'12-hour"'
and was unable to run till I did"'12-hour'"
although my time still the same. Is that a typo in the answer? – George Udosen Jan 21 '17 at 18:37 -
1Hi @George I am on mobile currently, but I am pretty sure you are right, I will edit it in. Thanks a lot! – Jacob Vlijm Jan 21 '17 at 19:54
-
I used the code in Ubuntu Mate 18.04 and it worked fine. But when I restart the PC, it is back to 24Hour format again. – Ahmad Ismail May 22 '18 at 12:29
It is not clear to me what exactly do you want. If you want just display the hour in your terminal window, you can try:
date +%R
date +%r
date +%H
date +%I
date +%H:%M
date +%I:%M
These are different time formats used to customize your time display. %R
uses time with 24 hour and %r
uses 12 hour format to display the whole time. If you want just hour with no minutes, etc. you can use %H
(24 hour) or %I
(12 hour). You can also combine them with minutes like that %H:%M
, %I:%M
. There are many other options. Take a look with man date
.
Then if you want to change the system global date display go to Settings -> Region & Language
.
There is also environment setting LC_TIME
specifiying how time & date are displayed. In my case I can set it up in /etc/environment
file like this:
LC_TIME="sl_SI.UTF-8"
You can also take a look at /etc/localtime
. Try:
ls -l /etc/localtime
This file is linked to some file from /usr/share/zoneinfo/
. Make a link like this:
ln -sf /usr/share/zoneinfo/Europe/Ljubljana /etc/localtime
and your local settings will be set to European Ljubljana, for instance. Fell free to use any other file from /usr/share/zoneinfo/
. However, I believe this last settings is only setting for the timezone and not how the date & time are displayed.

- 4,362
-
I've linked /etc/localtime to the appropriate timezone, but I still get a 12-hour format (but the right timezone offset from GMT). I have no LC* or other variables set. (I get the correct output with
LC_TIME=..... date
, but I would like to have 24-hour time as the default. – Ketil Malde Jan 05 '20 at 15:21 -
1Take a look here https://askubuntu.com/questions/918973/how-to-set-lc-time-variable-to-en-dk-while-keeping-en-us-the-system-default-for, how to setup LC_TIME. – nobody Jan 06 '20 at 07:33
-
Thanks. It might be that the locale needs to be "enabled". However, I discovered that
LANG
was set toen_US.UTF-8
in my shell, 'unset'ing this environment variable changed the output ofdate
to 24h format. (I haven't figured out how it got set in the first place, though.) – Ketil Malde Jan 07 '20 at 09:57 -
-
1@SamSirry :-) Read or pronounce? Try this https://ebralec.si/branje/?jezik=en. Paste
Ljubljana
in there and listen. – nobody Nov 13 '20 at 06:59
For new users, if you are using gnome on ubuntu version >18.04
gsettings set org.gnome.desktop.interface clock-format 12h
gsettings set org.gnome.desktop.interface clock-format 24h

- 512
The locale settings can affect the time display format for the date
command. E.g. With en_US
it is 12-hour:
% LANG='en_US.UTF-8'; date
Tue 14 Jul 2020 09:13:29 PM BST
And 24-hour for en_GB
:
% LANG='en_GB.UTF-8'; date
Tue 14 Jul 2020 21:13:29 PM BST
This can be changed for the system by running the following command (provided you have the appropriate language files installed):
sudo update-locale LANGUAGE=en_GB.UTF-8 LANG=en_GB.UTF-8

- 3,063
- 1
- 25
- 15
-
*** update-locale: Error: invalid locale settings: LANGUAGE=en_GB.UTF-8 LANG=en_GB.UTF-8
can be fixed withsudo locale-gen "en_GB.UTF-8"
– Henno Aug 19 '20 at 10:38 -
That error message usually means that the requested locale files are not installed - they can be installed:
sudo apt install language-pack-XX
– Pierz Aug 19 '20 at 10:53