Skip to content
Fragmented Development

Setting time, date, NTP, and timezone details on Debian

Setting date and time options on Debian has been placed under the systemd umbrella with the "timedatectl" utility. While I'm not fully convinced that everything belongs in systemd, I do think that having a single location for all time and date related configurations makes sense.

Set system date and time

You can use the set-time command with timedatectl to set either the time, date, or both simultaneously. Because it is a system-wide setting, this command does need to be run with root privileges.

# Sets the system time (hours, minutes, seconds)
# note: time and date values may need to be quoted
timedatectl set-time [hh:mm:ss]

# Set the system date
timedatectl set-time [yyyy-mm-dd]

# Set both time and date
timedatectl set-time [yyyy-mm-dd hh:mm:ss]

Set NTP synchronization

Since it's always good to keep synced up with the rest of the world, turning on NTP is a great idea. My Debian machine DID NOT do synchronization automatically, so this is a good option to set.

# Enable NTP (switch to "false" to disable, if that's how you roll)
timedatectl set-ntp true

Enabling this option did not request any pool information, or have any changeable settings that I could see, so they may be configured elsewhere. I'll update this post if I find any additional information.

Set timezones

There are two commands for setting timezones; one that lists the available options, and one that sets the desired timezone.

# List the available timezone values that you can use
timedatectl list-timezones

# Set the timezone (I used "America/New_York" to switch to Eastern US time )
timedatectl set-timezone [timezone]

My window manager (i3) did not pick up the timezone settings immediately when I changed. You may need to restart your WM/session for them to pick up, or make sure that you haven't manually specified one in your bash profile/config ( export TZ=America/Los_Angeles, for example ).

Tags: linux server


Add Your Comment