Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My /etc/localtime on my Ubuntu gives my correct timezone - EAT which is UTC +3. The date command gives the time as 21:44:58 EAT which is about the correct time (I'm not concerned about accuracy to the second in this question).

However, when I do sudo hwclock -r, it gives my time as 12:44:31 AM EAT, which is approximately three hours ahead of the correct time. I assume that the hardware clock assumes the 21:44 is in UTC.

Running the command ntpdate ntp.ubuntu.com has no effect on the hardware clock (it returns 21:44:23).

When I invoke the python interpretter and do:

import datetime
print datetime.datetime.utcnow()

It gives me 18:44:36, which is the correct UTC time (as per now).

So is it that although the hardware clock is wrong, the Operating System maintains it's own correct time? As this seems to 'go against the manual' can I safely modify the hardware clock without messing up with some other time component?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The operating system knows that your hardware clock is set to localtime, not UTC. This is a configurable system parameter. Linux tools that use system facilities for date/timezone management will produce the correct time. hwclock -r is guessing that your hardware clock is set to UTC, but it is guessing wrong and adding three hours when it shouldn't.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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