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!!
Time settings, as as shown in the panel, are set with
gsettings. You can set 12/24 hrs by the commands:
gsettings set com.canonical.indicator.datetime time-format 12-hour
gsettings set com.canonical.indicator.datetime time-format 24-hour
locale-default 12-hour 24-hour custom
The same trick on Mate
...requires a different command:
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!)
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
%I:%M. There are many other options. Take a look with
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:
You can also take a look at
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.
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
% 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