💾 Archived View for darknesscode.xyz › notes › datetimectl.gmi captured on 2024-02-05 at 09:43:43. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-05)

-=-=-=-=-=-=-

Datetimectl

About systemd based Linux system, with systemd based system you need to use the timedatectl command to set or view the current date and time.

Check the date/time

timedatectl

The output will be something like

Local time: Sun 2021-01-17 21:21:21 PST
           Universal time: Mon 2021-01-18 05:21:21 UTC
                 RTC time: Mon 2021-01-18 05:21:27
                Time zone: America/Los_Angeles (PST, -0800)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no

To change both the date and time, use the following syntax:

timedatectl set-time YYYY-MM-DD HH:MM:SS

Where

HH : An hour.
MM : A minute.
SS : A second, all typed in two-digit form.
YYYY: A four-digit year.
MM : A two-digit month.
DD: A two-digit day of the month.

Example

timedatectl set-time '2021-01-16 11:04:20'

Set the current time or date only

The syntax for time

timedatectl set-time HH:MM:SS

The syntax for date

timedatectl set-time YYYY-MM-DD

Set the time zone

timedatectl set-timezone 'Asia/Kolkata'

Synchronizing the system clock with a remote server using NTP

Simply type the following command:

timedatectl set-ntp yes

----------

Home

Linux

Notes

MicroLog

----------

© DarknessCode