Raspberry Pi desktop – Set time format
January 20th, 2024 7:01 PM Mr. Q Categories: Rasberry PI
To set the time format on the Raspberry Pi desktop, you can use the raspi-config
tool or manually configure the time settings. Here are instructions for both methods:
Using raspi-config:
1) Open a terminal on your Raspberry Pi.
2) Run the following command to open the raspi-config
tool:
sudo raspi-config
3) Navigate to Localisation Options.
4) Select Change Timezone.
5) Choose your geographical area and city from the list.
6) Once done, you may also want to go back to the main menu and select Change Locale if you want to set your locale settings
7) After making changes, reboot your Raspberry Pi for the changes to take effect:
sudo reboot
Manual Configuration:
1) Open the raspi-config
tool:
sudo raspi-config
2) Navigate to Localisation Options.
3) Select Change Timezone and choose your geographical area and city.
4) Save the changes and exit the raspi-config
tool.
5) Open the /etc/default/locale
file for editing
sudo nano /etc/default/locale
6) Set the LANG
variable to your desired locale. For example:
LANG=en_US.UTF-8
7) Save the changes and exit the text editor.
8) Open the /etc/environment
file for editing
sudo nano /etc/environment
9) Add the following line to set the time format. For example:
LC_TIME="en_US.UTF-8"
10) Save the changes and exit the text editor.
11) Reboot your Raspberry Pi:
sudo reboot
Time Format Variables:
The time format is controlled by the locale settings. Common time-related format variables include:
%H
: Hour (00-23)%I
: Hour (01-12)%M
: Minutes (00-59)%S
: Seconds (00-59)%p
: AM or PM%A
: Full weekday name%a
: Abbreviated weekday name%B
: Full month name%b
: Abbreviated month name
%r will give you a 12 hour clock with am/pm indicator
%R will give you a 24 hour clock
%X will give you a 24 hour clock with seconds
%x will give you the date in this format DD/MM/YY
%d will give you the day in number format
%D will give you the date in this format MM/DD/YY
%a will give you the abbreviated day name
%A will give you the full day name
For example, if you want to set the time format to 24-hour format with seconds, you can use:
LC_TIME="en_US.UTF-8"
You can customize the format based on your preferences and the variables mentioned above.
pi@raspberrypi:~ $ /bin/date '+%_A, %B %-d, %Y %H%M %Z'
Wednesday, January 4, 2017 2157 GMT
%a / %h, %d %Y / %I:%M %p
Tuesday /
Reference
https://en.wikipedia.org/wiki/ISO_8601