It is very essential to have your system configured with the proper date and time. Mostly the Debian OS uses NTP to synchronize time over a network. However, sometimes, you need to manually set the date and time in your system.
In this post, we will show how to change the date, time, and timezone in your Debian system. Debian OS allows you to change your system date, time, and timezone through the following two methods:
- Through Command Line
- Through GUI
Note: Before proceeding, it’s worth mentioning that all the commands and procedures shown in this post have been tested on Debian 10 (Buster).
Changing the Date, Time, and Timezone through Command Line
The “timedatectl” command is used to view and change the current date, time, and timezone of a system. Let’s get started:
View Current Date, Time, and Timezone
To view the current date, time, and timezone, you can either use the “date” or “timedatectl” command.
Using the “date” command
In order to view the current date, time, and timezone, simply execute the date command in Terminal:
$ date
This command shows the day of the week, month name, day of the month, time, timezone name, and year:
Using the “timedatectl” command
In order to view the current date, time, and timezone, simply execute the timedatectl command in Terminal:
$ timedatectl
This command displays the local time as well as the universal and RTC time. It also displays complete information about the timezone.
To find your system’s current time information, view the first line of output. This line displays the day of the week, date, time, and timezone information.
If you notice in the above screenshot, the NTP service is “active”. For manually configuring the date, time, and timezone in your Debian system, you will need to turn off the NTP service. Run the following command in Terminal to do so:
$ timedatectl set-ntp no
Now again run the timedatectl command to view if the service status has changed to “inactive”.
Changing the Date
In order to change the date in the Debian system, run the timedatectl command using the following syntax:
$ timedatectl set-time YYYY-MM-DD
In the above command,
- “YYYY” represents the year
- “MM” represents the month (01-12)
- “DD” represents (01-31)
In order to set the date to let’s say: 2020-12-26 (26th December 2020), the command would be:
$ timedatectl set-time 2020-12-26
Once you have set the date, run the following command to view if it has changed successfully:
$ timedatectl
The following output shows the date has been changed to our desired value 2020-12-26.
Changing the Time
In order to change the time in the Debian system, run the timedatectl command using the following syntax:
$ timedatectl set-time hh-mm-ss
In the above command,
- “hh” represents hours (00-24)
- “mm” represents minutes (00-59)
- “ss” represents seconds (00-59)
In order to set the time to let’s say: 18:40 (or 6:40 pm), the command would be:
$ timedatectl set-time 18:40
Once you have changed the time, run the following command to view if it has changed successfully:
$ timedatectl
The following output shows the time has been changed to our desired value 18:40.
Changing the Timezone
Similar to date and time, the timezone can also be changed using the timedatectl command. Before changing the timezone, you can list available timezones as follows:
$ timedatectl list-timezones
This command lists all the available timezones from which you can choose your desired timezone name.
In order to change the timezone in the Debian system, run the timedatectl command using the following syntax:
$ timedatectl set-timezone geographical region/city
For instance, to change the timezone to Asia/Dubai, the command would be:
$ timedatectl set-timezone Asia/Dubai
Once you have changed the timezone, run the following command to view if it has changed successfully:
$ timedatectl
The following output shows the timezone has been successfully changed to Asia/Dubai.
Changing the Date, Time, and Timezone through GUI
For users who prefer working with GUI, here is how they can change the date, time, and timezone in their Debian system.
View Current Date, Time, and Timezone
In order to view the current date, time, and timezone, hit the super key on the keyboard and type date & time. Then from the search results, click Date & Time.
It opens the Settings utility in the Date & Time view. Here you can see your system’s current date, time, and timezone information.
Changing Date and Time
For changing the date and time, first, make sure the Automatic Date & Time switch is turned off. Now in order to change the date and time, click the Date and Time option as shown in the following screenshot:
The following Date & Time window will appear for you to manually choose the date and time. Once you have set the desired date and time, close the window.
Using the Time Format option, you can choose 24-hour or AM/PM time format.
Changing Timezone
For changing the timezone, first, make sure the Automatic Time Zone switch is turned off. Now in order to change the timezone, click TimeZone as shown in the following screenshot.
By clicking the TimeZone, you will see the following window with the map. Choose your location on the map or you can also use the search bar at top to search for your location. Once you do it, your timezone will be changed. After that, close the window.
By following the procedures discussed in this post, you can easily change the date, time, and timezone in your Debian system. Based on your convenience, you can either choose the command line or the GUI method. If you are using Ubuntu OS, you can visit our post on How to Change the Date, Time, and Timezone in Ubuntu 20.04 LTS.