Ubuntu has plenty of ways for users to display time. In this blog post, we’ll cover two different strategies: using the date command and the timedatectl command. No matter your level of tech savviness, sticking with us until the end will ensure that you have complete control over how time looks on your Ubuntu device!
Using Date Command In Ubuntu to display time
The date command is one of the simplest ways to display the current time in Ubuntu. By running this straightforward command, you can see the system’s time, as well as its timezone and UTC offset. To run it, open your terminal window (Ctrl+Alt+T) and enter:
You’ll get an output like this:
Tue Jun 11 20:20:18 PDT 2019
This output shows the day of the week, date, time, and your local timezone.
You can customize it to display only the information that you need. To do this, run the date command along with one or more flags:
$ date +%T
The %T flag stands for Time, and it prints only the time portion of the output.
Let’s see another example.
Here, the %Y character is replaced with the current year,%m with month, and %d with the day of the month:
date +"Year: %Y, Month: %m, Day: %d"
Year: 2022, Month: 04, Day: 16
The following are the date format options.
%D: Display date as mm/dd/yy.
%d: Display the day of the month (01 to 31).
%a: Displays the abbreviated name for weekdays (Sun to Sat).
%A: Displays full weekdays (Sunday to Saturday).
%h: Displays abbreviated month name (Jan to Dec).
%b: Displays abbreviated month name (Jan to Dec).
%B: Displays full month name(January to December).
%m: Displays the month of year (01 to 12).
%y: Displays last two digits of the year(00 to 99).
%Y: Display four-digit year.
%T: Display the time in 24 hour format as HH:MM:SS.
%H: Display the hour.
%M: Display the minute.
%S: Display the seconds.
Using timedatectl Command to display time
timedatectl is a modern command for checking and modifying your system’s time settings on Ubuntu. It provides much more information than the date command – you can view your local timezone, set up a new one, turn automatic Timezone synchronization on or off, and more.
To see all the details about your system’s time settings, run timedatectl in your terminal window:
Local time: Sat 2022-04-16 13:06:00 GMT
Universal time: Sat 2022-04-16 13:06:00 UTZ
RTC time: Sat 2022-04-16 13:02:34
Time zone: GMT (GMT, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: yes
To change the system time, use the set-time option. For example, to set the system time to 12:00pm on January 22nd, 2030, you would type the following command:
timedatectl set-time "2030-01-22 12:00:00"
And that’s it! With these two commands, you can easily check the time whenever you need to. Don’t forget to stay safe when working with terminal settings – always double-check your commands before running them!
Good luck and have fun!