When you install and run two operating systems, such as Windows and Linux (e.g., Ubuntu), in parallel on the same computer, you may encounter a problem where the system time between the two operating systems doesn't match. This issue occurs due to differences in how each operating system handles the hardware clock (RTC - Real-Time Clock).
The Root Cause
- Windows: By default, Windows sets the hardware clock to local time.
- Linux: Linux, on the other hand, assumes the hardware clock is in UTC (Coordinated Universal Time) and adjusts for the local time zone.
This discrepancy results in the time being incorrect on one of the operating systems when you switch between them.
Solution: Synchronizing the System Time Between Windows and Linux
Option 1: Configure Linux to Use Local Time
This is the easiest solution and doesn't affect Windows.
- Open the terminal in Linux.
Execute the following command to set Linux to use local time instead of UTC:
1
timedatectl set-local-rtc 1 --adjust-system-clock
Confirm the change with:
1
timedatectl
You should see a message like
RTC in local TZ: yes
.
Note: Using this method may cause issues with scheduled tasks in Linux, as most Linux systems are optimized for UTC.
Option 2: Configure Windows to Use UTC
This option adjusts Windows to use UTC instead of local time.
- Open the Windows Registry Editor:
- Press
Win + R
, typeregedit
, and press Enter.
- Press
Navigate to the following key:
1
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
- Create a new DWORD (32-bit) Value:
- Right-click on the right pane, select New > DWORD (32-bit) Value, and name it
RealTimeIsUniversal
.
- Right-click on the right pane, select New > DWORD (32-bit) Value, and name it
- Set the value of
RealTimeIsUniversal
to1
. - Restart your computer for the changes to take effect.
Recommendation
- Use Option 1 if you prefer a simpler approach with minimal configuration changes.
- Use Option 2 if you primarily work in Linux or if you need to follow best practices for managing time in distributed systems.
Both methods ensure that the system time remains consistent across operating systems when running Windows and Linux in parallel.
Related: