I have the following problem on a CentOS 6.5 system running under VirtualBox v4.2.4 on Windows 7 Pro SP1.

date always prints a UTC time but with the correct timezone shown, e.g. if I run date at 12:35 pm I get this:

$ date
Fri Mar 20 04:35:45 AWST 2015

I've tried the following, none of which worked. I rebooted after each step.

  1. edited /etc/sysconfig/clock and changed UTC=false to UTC=true
  2. run sudo yum erase ntp as indicated by the VirtualBox bug report Guest additions confuse clock in linux guest (windows 7 host)
  3. ran sudo yum update tzdata
  4. edited /etc/sysconfig/clock and removed UTC=true completely

I confirmed the following:

  • the time and timezone are set correctly on the physical Windows 7 machine
  • looked in the Machine settings in VirtualBox; "Hardware clock in UTC time" is ticked
  • the output of zdump -v /etc/localtime is fine
  • env | grep TZ shows nothing
  • /etc/localtime was updated by sudo yum update tzdata
  • /etc/localtime and /usr/share/zoneinfo/Australia/Perth have the same MD5 hash
  • TZ=utc hwclock -r shows the correct UTC time
  • vBox guest additions are not installed (I got no output from lsmod | grep vboxadd)

It's worth noting that I looked for where the CentOS boot scripts read /etc/sysconfig/clock but couldn't find anything. This is in contrast to Debian/Ubuntu, which have /etc/init.d/hwclockfirst.sh that runs early in the userspace part of the boot process and fixes the system time according to /etc/default/rcS which has UTC=yes or UTC=no.

  • See CentOS Ignoring Timezone and showing UTC question on serverfault. I tried the suggestions there; let me know if I missed any. – Alastair Irvine Mar 20 '15 at 5:22
  • 1
    What does 'date ; date -u' display? I can't tell if your clock is just off or if your TZ database isn't working. – BowlOfRed Mar 20 '15 at 7:09
  • "Fri Mar 20 10:36:26 AWST 2015" and "Fri Mar 20 02:36:26 UTC 2015". As you can see from my TZ=utc hwclock -r observation the "hardware" clock from VirtualBox appears to be set to the correct UTC time. – Alastair Irvine Mar 20 '15 at 10:36
  • 1
    What do you get from hwclock --show --debug? – BowlOfRed Mar 20 '15 at 15:41

Your Answer

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

Browse other questions tagged or ask your own question.