In the following of Ubuntu articles, we are going to learn you how to set date and time on Ubuntu 18. So that your server automatically adjusts its time and date. An operating system detects and synchronizes time using NIST which operates an atomic clock that never gains or loses a second in 300 million years. This guide can help you how to change the time, date, check, and timezone in Ubuntu.
Set date and time on Ubuntu 18
Display date and time in Ubuntu 18
1- The easiest way to view the system clock and date in Ubuntu 18 is to use the date command.
2- After entering the above command, you will receive the same output as the following phrase.
Output Tue Jul 10 14:48:52 UTC 2018
Note: In the above phrase, if you notice, the word UTC indicates that your time zone is set to 0. Now with the UTC setting, the server will be able to completely set the time and date to synchronize.
Set date and time on Ubuntu 18 by timedatectl command
1- You can use the timedatectl command to set the time zone.
2- This command will be able to list different time zones for you and set each time zone for you.
Now enter the following command to view the list of time zones.
Point: After entering the above command, you will see a list of time zones where you can click the Space key on your keyboard to see the rest of the list on the next page, or use it to return to a page before, the b key. After selecting the time zone, press the q key to exit the list.
3- To set an area when you have selected from the list, enter the following command along with its name to set the Time Zone of your server.
timedatectl set-timezone America/New_York
Note: The name of the time zone must be exactly the same as the phrase displayed in the Time Zone list.
4- After setting up, enter the date command once again to make sure the changes are correct.
5- If your Time Zone has changed, the output of the date command will be similar to the following statements.
Output Tue Jul 10 10:50:53 EDT 2018
Synchronize date and time in Ubuntu 18
So far, you’ve seen the server’s time and date, as well as its Time Zone setting.
1- Now enter the following command to ensure the system date and time are synchronized with the hardware clock.
2- The output of the above command should be similar to the following statements.
Local time: Tue 2018-07-10 10:54:12 EDT Universal time: Tue 2018-07-10 14:54:12 UTC RTC time: Tue 2018-07-10 14:54:12 Time zone: America/New_York (EDT, -0400) System clock synchronized: yes systemd-timesyncd.service active: yes RTC in local TZ: no
3- If there is “No” in front of the phrase System clock synchronizes or systemd-timesyncd.service, the following command must be entered to synchronize.
timedatectl set-ntp on
This way you will be able to set the time and date of your system with the help of your server’s time zone.
Dear user, we hope you would enjoy this tutorial, you can ask questions about this training in the comments section, or to solve other problems in the field of Eldernode training, refer to the Ask page section and raise your problems in it.