11

From what I've read the hwclock -r command only returns the time in local time no matter how it is set. I think hwclock --utc or hwclock --localtime will change the clock to UTC or localtime. But I don't want to change it; I want to know how it is currently set.

So how can I check if my hardware clock is set to UTC time or local time?

3
  • Check your BIOS setup. The computer's time is usually set here. Feb 2 '16 at 5:25
  • Which version of Ubuntu? What does grep -i utc /etc/default/rcS say?
    – muru
    Feb 2 '16 at 8:28
  • @muru that command returned UTC=no so I assume it was changing it based on the localtime. I changed that to UTC=yes and now the clock is working properly.
    – chaptuck
    Feb 2 '16 at 16:25
21

Ubuntu 15.04 and later uses systemd as the default init system and includes the timedatectl program. Running timedatectl will output:

      Local time: Tue 2016-02-02 09:47:54 MST
  Universal time: Tue 2016-02-02 16:47:54 UTC
        RTC time: Tue 2016-02-02 16:47:54
       Time zone: America/Denver (MST, -0700)
 Network time on: yes
NTP synchronized: no
 RTC in local TZ: no

RTC time is the hardware clock. Compare it to the Local time and Universal times returned by timedatectl to determine how the hardware clock is set.

RTC in local TZ: no means the hardware clock is interpreted as UTC

RTC in local TZ: yes means the hardware clock is interpreted as local time

To switch using timedatectl

sudo timedatectl set-local-rtc 0 sets RTC to UTC

sudo timedatectl set-local-rtc 1 sets RTC to local time

Switch using config file

Setting the UTC= setting in /etc/default/rcS will change how the system interprets the hardware clock (UTC=yes or UTC=no).

1
  • +1 for this answer being simple and does not require sudo Feb 2 '16 at 18:32
13
sudo hwclock --debug

Gives you the unmodified time before spitting out the interpreted (local or UTC) answer.

7
  • This was what I was hoping for thank you. The man pages weren't very descriptive for that option so I wasn't sure what it did.
    – chaptuck
    Feb 2 '16 at 16:26
  • 1
    timedatectl is better, you dont need sudo for it Feb 2 '16 at 17:33
  • @FriarTuck what is the correct answer is totally up to you, no judgement over it Feb 2 '16 at 18:26
  • I certainly don't mind =) Feb 2 '16 at 18:27
  • 1
    If your system does not have timedatectl, this is your best bet (for the googlers here)
    – Mat M
    Oct 12 '16 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.