Introduction
If you are using Ubuntu, you may need to set or change the time zone, date, and time on your system. This is especially important if you are using Ubuntu for a server, as the time and date settings can affect the accuracy of your system. Fortunately, setting or changing the time zone, date, and time on Ubuntu is a relatively simple process. In this guide, we will show you how to set or change the time zone, date, and time on Ubuntu.
How To Set or Change Time Zone/Date/Time on Ubuntu
18.04
1. Open the Settings app.
2. Select the “Time & Date” option.
3. Select the “Time Zone” tab.
4. Select your desired time zone from the list.
5. To change the date and time, select the “Date & Time” tab.
6. Select the “Change” button.
7. Enter the new date and time.
8. Select the “Change” button to save your changes.
Introduction
Modern operating systems detect and synchronize time using NIST (National Institute of Standards and Technology) time servers. NIST operates an atomic clock that neither gains nor loses a second in 300 million years.
However, you may find that your system needs to be synchronized with NIST time servers properly.
This guide shows you how to check and change Ubuntu’s time, date, and timezone.
Prerequisites
- Some operations may require sudo or root privileges
- The command line/terminal window (Ctrl-Alt-T)
Using timedatectl to Control the System Time and Date
Most modern Linux distributions such as Fedora, Debian, Ubuntu, Arch, CentOS v.7.x+, and other Unix-based systems provide the timedatectl
utility. This command allows you to control and edit time and date settings using the command line.
Display Current Date and Time with timedatectl
To display the current time and date information, use the command:
timedatectl
The output provides local time, universal time, and the timezone and informs you if the synchronization process is enabled.
Sync Time to NIST Atomic Clock
Set the Ubuntu system to synchronize to the NIST atomic clock with the following command:
timedatectl set-ntp yes
To adjust the time and date manually, turn off NTP synchronizing with:
timedatectl set-ntp no
Note: NTP stands for Network Time Protocol.
How to Change the Time
To set the time to your specifications, use the following command:
timedatectl set-time 21:45:53
The time format is HH:MM:SS
(Hours, Minutes, Seconds). Ensure the automatic time synchronization is off to enable changes.
How to Change the Date
Use the same command to define the date on the system:
timedatectl set-time 2019-04-10
The date format is YYYY-MM-DD
(Year, Month, and Day).
How to Set a Timezone in Ubuntu
The timedatectl
command additionally allows you to synchronize your systems with a time zone of your choosing. To change the time zone, follow the steps below:
1. To list the names of the time zones, use:
timedatectl list-timezones
2. Find the location closest to you, then enter the following:
timedatectl set-timezone Region/Location
3. Replace Region/Location
with a name from the time zone list.
The time zone list is extensive. Filter the list by keyword by piping the grep command:
timedatectl list-timezones | grep keyword
Substitute keyword
for any keyword you wish, such as America
, Asia
, or New_York
. If you get an error, double-check your spelling and make sure that you are using capital letters correctly.
How to Set Universal Time (UTC) in Ubuntu
UTC stands for Coordinated Universal Time and appears in scientific calculations and synchronizing between time zones across the globe. Synchronize your system with the following command:
timedatectl set-timezone UTC
There is no immediate output; however, you can check the applied settings with timedatectl
.
Note: GMT and Zulu Time are often used to refer to UTC. They are equivalent terms when fractions of a second are not relevant.
How to Sync Hardware Clock
RTC stands for Real-Time Clock, another name for the hardware clock the computer. The system has a tiny quartz crystal and a battery that keeps time when the system disconnects from a network.
Set Hardware Clock to Sync to Local Timezone
To have the Real-Time Clock synchronize to your local time zone, enter:
timedatectl set-local-rtc 1
You may get an error in this mode, since updating the hardware clock to the local time zone is unsupported.
Set the Hardware Clock to Sync with UTC
Set the hardware clock to synchronize with UTC by entering the following command:
timedatectl set-local-rtc 0
As with the previous command, there is no confirmation that the change has applied. Verify the change manually with the timedatectl
command.
Set Time, Date Timezone in Ubuntu Older Versions From Command Line
Older Ubuntu versions may not support the timedatectl
command. Find out how to check the Ubuntu version.
There are alternative commands to display and adjust system time setting from a command line. Use the commands listed below:
- To display the date and time of the operating system, use:
date
- Change the date of the operating system by typing:
sudo date -s "YY-MM-DD HH:MM:SS"
Replace YY-MM-DD
with Year-Month-Day, and HH:MM:SS
with Hour:Minute:Second. You can set just the date or only the time, depending on your needs.
- Display the time kept by the hardware clock (RTC) with any of the following commands:
sudo hwclock -r
or
sudo hwclock --show
or
sudo hwclock --show --verbose
Note: Some versions may not support the --verbose
option, and it may not work on a virtual machine. The hardware clock may not hold the same time as the operating system.
- Display the RTC time in UTC format:
sudo hwclock --show --utc
- Change the time kept by the RTC:
sudo hwclock --set --date "MM/DD/YY HH:MM:SS"
- Set OS time based on the hardware clock (RTC):
sudo hwclock --hctosys
This command tells the system to set the HC (hardware clock) to SYS (system):
- Set the RTC based on the operating system time:
sudo hwclock --systohc
Use this command to reverse the previous process.
Conclusion
This guide showed you how to set the time, date, and time zone on your Ubuntu system. Setting the system to synchronize with NTP is typically the best course of action.
How To Set or Change Time Zone/Date/Time on Ubuntu
Ubuntu is a popular Linux-based operating system that is used by many people around the world. It is important to keep the time zone and date/time settings on your Ubuntu system up to date, as this can affect the accuracy of your system’s clock and the functioning of certain applications. In this article, we will show you how to set or change the time zone, date, and time on Ubuntu.
Step 1: Open the Settings App
The first step is to open the Settings app. You can do this by clicking on the gear icon in the top right corner of your screen, or by pressing the Super key (Windows key) and typing “Settings”. Once the Settings app is open, click on the “Date & Time” option.
Step 2: Change the Time Zone
The first thing you will see in the Date & Time settings is the time zone. To change the time zone, click on the drop-down menu and select the time zone you want to use. You can also type in the name of the time zone in the search box to quickly find it.
Step 3: Change the Date and Time
Once you have set the time zone, you can then change the date and time. To do this, click on the “Change” button next to the date and time. This will open a window where you can enter the new date and time. Once you have entered the new date and time, click “OK” to save the changes.
Step 4: Apply the Changes
Once you have made the changes, you need to apply them. To do this, click on the “Apply” button at the bottom of the Date & Time settings window. This will apply the changes and your system will now be using the new time zone, date, and time.
Conclusion
In this article, we have shown you how to set or change the time zone, date, and time on Ubuntu. We hope this has been helpful and that you now have a better understanding of how to manage the time settings on your system. If you have any questions or comments, please feel free to leave them in the comments section below.