Wrong time displayed when dual booting

From PCLinuxOS Knowledgebase
Revision as of 06:26, 29 October 2024 by CoreLite (talk | contribs) (→‎How to fix the problem)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Wrong Time Displayed in Windows on a Dual Boot computer with Linux

  • Relevant to PCLinuxOS (any version) when dual booting Windows 10 or 11

Introduction

After installing Linux to dual boot with Windows, the wrong time appears on the Taskbar when you boot back in to Windows

Linux and Windows both get the time from the same source. The computer has two primary clocks – the hardware clock and the system clock. The system clock is what you see on the taskbar. The hardware clock is the motherboard clock that you set up in the UEFI/BIOS. When you boot the computer up, the system clock reads the time from the hardware clock and keeps time until the computer is shut down.

The problem is caused by the different way that the two operating systems calculate the time based on that reading from the hardware clock. Windows sees the time from the hardware clock as Local Time, which is the time that that you set in the BIOS. Linux sees the hardware clock time as UTC (Universal Time), and then calculates the local time from the Time Zone that you selected during the installation. In my case, the local time is UTC minus 5 hours. If my hardware clock shows 12:00 noon, Linux displays that as the local time and syncs the hardware clock to what it thinks is UTC, or 5:00 PM. When you shut down Linux and boot into Windows, Windows sees the hardware clock showing 5:00 PM and thinks that is local time, when in fact, it is 5 hours ahead.

How to fix the problem

There are a few different ways to fix this problem. Fixing it in Windows requires a Registry hack. We won’t go there. One way to fix it in Linux involves changing /etc/adjtime with a text editor.

The easy way to fix it is a simple one line command in Konsole.

Log in to Linux as root and enter this command:

hwclock -w -l

That has the same effect as editing /etc/adjtime.

You will not see a change on your Linux desktop, but the next time you boot into Windows, you will see the correct time on the taskbar.