×


Modify Date, Time, and Timezone in Debian 10 - How to do it ?

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.

To see the time on a Debian GNU/Linux system, use the command date, without arguments it will show system time respecting the currently defined timezone. 

To see the time in the UTC timezone, use the command date --utc (or shorthand date -u).

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Debian related queries.

In this context we shall look into how to change the date, time, and timezone in your Debian system.


How to Modify Date, Time, and Timezone on Debian 10 ?

Debian OS allows you to change your system date, time, and timezone through the following two methods:

i. Through Command Line

ii. Through GUI


How to change 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.


To 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.

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".


How to modify the Date on Debian System using timedatectl ?

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,

i. "YYYY" represents the year

ii. "MM" represents the month (01-12)

iii. "DD" represents (01-31)


In order to set the date to let's say: 2021-01-05 (5th January 2021), the command would be:

$ timedatectl set-time 2021-01-05

Once you have set the date, run the following command to view if it has changed successfully:

$ timedatectl


How to change the time on Debian using timedatectl ?

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,

i. "hh" represents hours (00-24)

ii. "mm" represents minutes (00-59)

iii. "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


How to change the Timezone on Debian using timedatectl ?

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


How to modify the Date, Time, and Timezone through GUI ?

If you prefer working with GUI, here is how they can change the date, time, and timezone in their Debian system.


How to View Current Date, Time, and Timezone via GUI ?

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 will see your system's current date, time, and timezone information.


How to modify Date and Time via GUI ?

To change 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.

From the Date & Time window, you can 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.


How to modify Timezone via GUI ?

To change the timezone, first, make sure the Automatic Time Zone switch is turned off. 

Now in order to change the timezone, click TimeZone.

By clicking the TimeZone, you will see a 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.


[Need urgent assistance to install missing packages on Debian System? We are available to help you. ]


Conclusion

This article covers how you can easily change the date, time, and timezone in your Debian system. To change your Debian system's timezone, run the sudo timedatectl set-timezone command followed by the long name of the time zone you want to set

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 .


Using the correct timezone is essential for many systems related tasks and processes. 

For example, the cron daemon uses the system's timezone for executing cron jobs, and the timestamps in the log files are based on the same system's timezone.

On Debian, the system's timezone is set during the install, but it can be easily changed at a later time.


To check the Current Timezone:

timedatectl is a command-line utility that allows you to view and change the system's time and date. It is available on all modern systemd-based Linux systems:

$ timedatectl


To modify Change Time Zone in Debian 10 / Debian 9:

1. Using /etc/localtime File. In this method, we will use /etc/localtime (link to the original time zone file) file to set the timezone for your system.

2. Using timedatectl command. In this method, we will use the timedatectl command to change the time zone in Debian.