In this day and age when people have multiple devices such as a PC and one or even multiple laptops or ultrabooks, dual booting might not be as common. Still, many people use a dual boot set up on their primary or secondary PC depending on their requirements. I have a dual boot set up on my primary laptop because it’s the one I carry around with me. I use both Ubuntu and Windows 10. They have their pros and cons, and I need both. Ubuntu like many other non-windows operating systems does support dual-booting because they have to. Windows 10, on the other hand, usually ships with settings that are not optimal for dual boot setups. This creates a couple of minor problems, one of which is Windows 10 displaying wrong time when you switch from Ubuntu to Windows 10. Fortunately, there’s an easy way to fix time between Windows 10 and Ubuntu in a dual boot set up.
Why does it happen?
This happens because Ubuntu stores time on the hardware clock as UTC (Coordinated Universal Time) by default. Windows 10, and even prior versions store the time as local time. Sometimes, not always, this causes conflicting times between Ubuntu and Windows. So as long as you’re only rebooting to Windows the clock will work just fine. Once you’ve booted Ubuntu, it writes the UTC time on the hardware clock. Now when you reboot to Windows, the time will be off by the exact amount as your local time differs from UTC. For example, the UTC time in India is UTC+5:30 so when the time in Windows 10 is off, it’s always 5 hours and 30 minutes behind the actual time.
How to Fix Time between Windows 10 and Ubuntu
This is just one the few minor problems you may come across when you have a dual boot setup. Now that we know the cause, we can easily fix the time between Windows 10 and Ubuntu by either making Ubuntu use local time or making Windows 10 use the UTC time. There are a couple of ways to do this. You can use either of the operating systems to do this.
Disable UTC and use Local Time in Ubuntu (Not recommended)
Note: According to Ubuntu wiki, “the advantage of having the hardware clock as UTC is that you don’t need to change the hardware clock when moving between time zones or when Daylight Savings Time (DST) begins or ends as UTC does not have DST or timezone offsets“. We’d recommend then that you shouldn’t use this method especially if you live in a place that uses Daylight Savings. It should be fine if you live in a country like India, yet we’d recommend that you use the second method. That is, fix this from Windows instead.
For Ubuntu 16.04 and newer, execute the following command in a terminal.
timedatectl set-local-rtc 1
This will change the required setting and you can see if it worked by using the following command.
You’ll see a bunch of lines as the output, but you just have to look for the line that says, “RTC in local TZ: yes”. You will also see a warning message that begins with “The system is configured to read the RTC time in the local time zone.” Further lines will warn you of the disadvantages of doing this.
For Ubuntu versions older than 16.04, you’ll be required to edit the config file
/etc/default/rcS and change “UTC=no” to “UTC=yes” (without quotes). This can also be done by a simple command which you can just copy and paste in the Terminal and then hit Enter.
sudo sed -i 's/UTC=yes/UTC=no/' /etc/default/rcS
You will be required to enter your password since the file is located in the root directory and you’re using a root command to modify it. After executing this command you’ll have to reboot your system for the changes to take effect.
Make Windows 10 use UTC (recommended)
Whereas changing Ubuntu to use local time instead of UTC had its disadvantages, making Windows 10 use the UTC time will only bring the advantages of using UTC time. This is why this is the recommended method. Download the registry file from the link below and double click on it to run the file. Click Run on the dialog box that opens and confirm your actions if asked to.
Even with the registry fix, Windows will continue to write local time. You’ll now need to launch a command prompt window as an administrator and execute the following command.
You can copy the command and right-click in command prompt to paste it. Reboot your system once done.