48

Ever since I started using Linux in dualboot with Windows I noticed that when I rebooted the machine, the time on the other OS was wrong, e.g. it was 12:00 on Linux, then I rebooted and on Windows it was 18:00, and when I checked the BIOS, the RTC was set to 18:00. Since my timezone is -06:00 CST I assume Linux just sets the RTC’s time to UTC and re-calculates the time based on the timezone, whereas Windows just sets the RTC to the local time. Both use the same NTP server to sync the time.

The question is, which one is doing the right thing? On which one should I set the timezone setting to UTC in order to have the right time on both?

2

5 Answers 5

19

Neither is wrong, but using UTC is more right. The RTC doesn't have a time zone; it's just a dumb wall clock. If your local time zone honors DST (of which there are many flavors, and rules change arbitrarily), then twice a year, you have to go and change it. The OS will do it for you, but if the RTC is UTC, the OS does the UTC->local translation anyway -- why fiddle with the clock? Furthermore, during the DST "fall back" transition, the RTC can't tell you what time it is! Is it 1:30am CDT or CST?

Apparently, Windows 8 supports UTC for the RTC. Windows 7 also did, but there were issues.

There was a better argument against this back when people set their BIOS clocks manually, but server-based time is much more prevalent now.

77

I recently faced the same problem and this is how I fixed it. You need to do a little change in both OS.

I started with Linux first. Run these following commands as root.

ntpdate pool.ntp.org

This will update your time if not set correctly.

Now set the hardware clock to UTC with this command.

hwclock --systohc --utc

Source

Now boot to Windows and add the following registry. Just simply create a .reg file using the code below in Notepad. Save it and run it.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001

Source

From next boot onward both OS will show you the correct time.

10
  • 2
    Should include what editions of Windows the registry tweak applies to.
    – Tanath
    Mar 2, 2015 at 18:15
  • 3
    When did Windows gain the ability to understand a system clock that keeps a time other than local?
    – Mark
    Mar 2, 2015 at 22:14
  • 2
    This registry tweak works for Windows XP/Vista/7/8/8.1. @Tanath
    – Ayan
    Mar 3, 2015 at 1:06
  • 4
    @Mark In Windows XP. Mar 3, 2015 at 12:35
  • 2
    So the Reg change (RealTimeIsUniversal=1) will make Win understand that RTC is UTC.
    – Tilo
    Nov 6, 2016 at 2:20
5

The normal case is that Linux systems have the RTC (real-time clock) set to UTC, and the conversion to local time is done in userspace based on time zone data and the TZ environment variable. This is "less bad" because it keeps the system RTC monotonically increasing, and applies any time zone magic later, ensuring for example that no files will normally have a timestamp in the future (which can easily happen at least once a year, if the system RTC is set to local time). As Ken pointed out, the RTC itself has no concept of a time zone, only time.

As you have found, this causes issues when dual-booting with a system that does not normally operate that way, like the Microsoft family of operating systems which generally expect the RTC to be set to local time. Yes, Windows NT (I think going all the way back to NT 4, actually) can work with the RTC set to UTC, but at least last I looked it wasn't really a supported configuration and there were a number of caveats.

The easy solution in your case is probably to set the RTC to local time, tell your Linux system that the RTC is set to local time (the exact mechanics of doing this varies by distribution and release version, but apparently in Ubuntu you set UTC=no in /etc/default/rcS), and then configure the operating systems such that only one of them (preferably the one you use the most, since the time displayed in all others will be incorrect twice a year until it has been booted and had a chance to correct it) handles daylight saving time changes. And live with the downsides, which should be managable on a single-user system.

You could also set the Windows side to use UTC as a time zone and turn off automatic daylight saving time changes in Windows, and keep Linux set to have the RTC in UTC and display the time converted according to its practices. However, this will cause Windows to display the date and time in UTC, which might not be what you really want. It's not a big issue for us Europeans, who are at most something like three hours off from UTC, but might be more of an issue in the US. This is likely more realistic an option if you only use Windows occasionally, and your primary OS is Linux or some other RTC-UTC-aware OS.

2
  • Do you have any information about "it wasn't really a supported configuration and there were a number of caveats."?
    – Random832
    Mar 2, 2015 at 18:31
  • @Random832 Let me see if I can find that. I know I've seen it before, but now can't seem to find it with a quick google search at least.
    – user
    Mar 3, 2015 at 8:27
2

If you dual boot and there are time conflicts between Windows and Ubuntu, this occurs because Ubuntu store the time on the hardware clock as UTC by default while Microsoft Windows stores the time as local time, thus causing conflicting times between Ubuntu and Windows.

You need to set your Linux system to use local time as explained here in this guide for Ubuntu.

4
  • It IS using local time, and I am aware that it indeed stores the time as UTC (if you at least read the question), and I know what can I do to fix this, the question is which one actually does the right thing to change the other instead.
    – arielnmz
    Mar 2, 2015 at 1:08
  • By default, Windows uses localtime, Mac OS uses UTC, and UNIX-like operating systems vary. An OS that uses the UTC standard, generally, will consider CMOS (hardware clock) time a UTC time (GMT, Greenwich time) and make an adjustment to it while setting the System time on boot according to your time zone.
    – user423645
    Mar 2, 2015 at 1:18
  • Again, I am aware of that, I just want to know which OS do it right so I can e.g. set windows timezone to UTC and fix this, or just the other way around.
    – arielnmz
    Mar 2, 2015 at 1:21
  • @MagomedSegaIsmailov Does Mac OS run on any systems that use BIOS RTC? I'd have assumed that EFI provided some sanity.
    – Random832
    Mar 3, 2015 at 22:21
0

Choose your own adventure!

You can either fix it on Linux or on Windows 11 (if you are already there!)

Windows 11

My preferred solution, thank you for coming here.

Open an administrator cmd console (Search -> "cmd" -> Right click on "Command Prompt" -> Run as administrator). And type in the command:

reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation" /v RealTimeIsUniversal /d 1 /t REG_DWORD /f

It will add a registry entry that will make everything work. As a final touch, to avoid restarting and all that (to fix current time), just click on Settings -> Time & Language -> Date & Time -> Set time automatically -> Off and then On again (just like in the IT crowd).

Linux

Type in this command (it might screw daylight savings calculations though! Careful what country you live in!).

timedatectl set-local-rtc 1 --adjust-system-clock

To undo this run

timedatectl set-local-rtc 0

ref source https://ubuntuhandbook.org/index.php/2021/06/incorrect-time-windows-11-dual-boot-ubuntu/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .