Skip to Content

3 ways to change time in Ubuntu

In this blog post, we will discuss three ways to change the time on your Ubuntu machine. The first way is to use the date command, the second way is to use the timedatectl command. The third way is to use hwclock command. We will also discuss some of the pros and cons of each method. Let’s get started!

change time on Ubuntu with date command

The date command is the most common way to change the time on the Ubuntu machine. To use the date command to change time, you will need to be logged in as the root user. Once you are logged in as the root user, you can issue the following command:

date -s “YYYY-MM-DD HH:MM:SS”

Where “YYYY-MM-DD HH:MM:SS” is the new date and time that you want to set. For example, if you wanted to set the date and time to January 15th, 2030 at 12:00pm, you would issue the following command:

date -s “2030-01-15 12:00:00”

Once you have issued the command, the date and time on your Ubuntu machine will be updated.

change time on Ubuntu with timedatectl command

Another way to change the current time in Ubuntu is to use the timedatectl command. It is a powerful tool in Ubuntu for managing system time and date settings, and it can be used to change the current time as well.

Here’s how you can use timedatectl to set the system time to a specific value:

  1. Open a terminal window by pressing Ctrl+Alt+T or by searching for “Terminal” in the Applications menu.
  2. Type the following command to set the system time to a specific value (replace “YYYY-MM-DD HH:MM:SS” with the desired date and time in the format of “year-month-day hour:minute:second”):sudo timedatectl set-time 'YYYY-MM-DD HH:MM:SS'
  3. Press Enter and enter your password when prompted.
  4. Verify that the new system time has been set by running the following command timedatectl. This command will display the current system time, as well as other time-related information.

For example, if you wanted to set the system time and date to January 15th, 2030 at 12:00pm, you would type the following command:

timedatectl set-time “2030-01-15 12:00:00”

change time on Ubuntu with Hwclock command

The hwclock command is another way to change the time on your Ubuntu machine. The hwclock command will update the hardware clock on your machine, which is independent of the system clock.

The hardware clock is typically implemented as a small, battery-powered quartz crystal oscillator circuit that runs independently of the computer’s main processor. When the system is powered off or rebooted, the hardware clock continues to keep track of time by using its own power source.

The hardware clock is used by the system to set the initial system time when the computer boots up. The system time is then adjusted periodically by software using information from the hardware clock and other time sources, such as network time servers.

To use the hwclock command, you will need to be logged in as the root user. Once you are logged in as the root user, you can issue the following command: hwclock -w

This will write the current system time to the hardware clock. Keep in mind that this change is permanent and will not be reverted after you reboot your machine.

We hope that this blog post has been helpful in showing you how to change the time on your Ubuntu machine. If you have any questions, please feel free to leave a comment below and we will do our best to answer them.

deirdx

Sunday 2nd of July 2023

cool. It is very helpful.