Different times for windows and ubuntu. Time is lost in Ubuntu and Windows

There are times when when installing a second system, this usually happens linux, the time in the systems begins to go wrong, for example, you were working under your linux and decided to move to windows, and found that the time and date are completely wrong, or vice versa, this is due to differences in the time format, these operating systems work with it differently, a little theory, and so, let's start with linux, these operating systems work with UTC
UTC- both hardware and software clocks are based on Greenwich Mean Time. That is, the clock gives universal time in the zero time zone. For example, if your time zone is GMT+3, Moscow, then the clock will be three hours behind. And users locally add to this time a correction for the time zone, for example, plus +3. Each user adds the amendment he needs. This is done on the servers so that each user can get the correct time for their time zone.
windows in turn works with localtime
localtime- in this version, the software clock also runs according to Greenwich Mean Time, but the hardware clock runs according to the time of the local time zone. There is no difference for the user; you still need to add an adjustment to your time zone. But when loading and synchronizing the time, Windows subtracts 3 hours (or some other time zone adjustment) from the hardware time so that the software time is correct.
so, we seem to have sorted out the theory, now let’s move on to practice, and so, at the beginning we’ll load up on our windows, launch the console as administrator and execute commands for a 32-bit system
Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1
or for 64 bit
Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_QWORD /d 1
but the clock will still be synchronized with the server time; to do this, turn off the clock synchronization service
sc config w32time start= disabled
Now we reboot our system and launch linux login to the terminal under root and execute the commands
timedatectl set-local-rtc 1 --adjust-system-clock
And
sed -i "s/UTC=yes/UTC=no/" /etc/default/rcS
look at the status of the hardware clock
sudo timedatectl
Now we reboot again, enter bios and set the date and time, check...
if for some reason we need to disable all this, then we execute the commands in Linux
timedatectl set-local-rtc 0
And
sed -i "s/UTC=no/UTC=yes/" /etc/default/rcS
in windows, console as administrator
Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 0
And
sc config w32time start= demand
Another option would be the following, in linux debian and derivatives
run the command to set the local time
sudo hwclock --localtime --adjust
if we want to return it back
sudo hwclock --utc --adjust
now let's check
timedatectl | grep local
if the answer
RTC in local TZ: no
then our time is ticking according to Greenwich, but if the answer
RTC in local TZ: yes
that means our time is ticking according to the system established
that's all, I think it was useful to you

In UEFI mode (Secure Boot). My BIOS time is correct.

When I boot into Ubuntu and then boot into Windows 10, it shows the wrong time. I have to fix it manually or online in Windows 10 and when I reboot into Windows 10 it is not a problem. The clock shows the correct time. And then when I reboot into Linux the clock is correct, but when going back to Windows 10 the clock starts working again.

Operating systems store and retrieve time in a hardware clock located on your motherboard to keep track of time even when the system is not powered. Most operating systems (Linux/Unix/Mac) store the time on the hardware clock as UTC by default, although some systems (notably Microsoft Windows) store the time on the hardware clock as "local" time. This causes problems on a dual boot system if both systems treat the hardware clock differently.

The advantage of using a hardware clock as UTC is that you don't have to change the hardware clock when moving between time zones or when Daylight Saving Time (DST) starts or ends, since UTC has no time or time offsets.

Changing Linux to use local time is easier and more reliable than changing Windows to use UTC, so dual boot Linux/Windows systems typically use local time.

Since Intrepid (8.10), UTC = yes is the default.

Make Windows use UTC

Note. This method was originally not supported in Windows Vista and Server 2008, but returned with Vista SP2, Windows 7, Server 2008 R2, and Windows 8/8.1.

So that MS Windows calculates the time from the hardware clock in UTC format.

Create a file named WindowsTimeFixUTC.reg with the following content, and then double-click it to merge the content into the registry:

Windows Registry Editor Version 5.00 "RealTimeIsUniversal"=dword:00000001

Note. The Windows Time service will still record local time in the RTC regardless of the registry setting above when turned off, so it is convenient to disable the Windows Time service using this command (if time synchronization is required while Windows is using some third party time synchronization):

Sc config w32time start= disabled

Cancel change

You can create a file with the following content and then double-click it to merge the original changes as above:

Windows Registry Editor Version 5.00 "RealTimeIsUniversal"=-

If the Windows Time service was disabled, enable it again using the command:

Sc config w32time start= demand

Make Linux "local" time

To tell your Ubuntu system that the hardware clock is set to "local" time:

  1. change /etc/default/rcS
  2. add or change the following section

    # Set UTC=yes if your hardware clock is set to UTC (GMT) UTC=no

Ubuntu 15.04 and higher systems (eg Ubuntu 16.04 LTS):

    open a terminal and run the following command

    If you want to see on our website answers to your questions about everything related to Apple technology, the Mac OS X operating system (and its launch on a PC), write to us via or.

    We received the following question:

    good afternoon!
    Hackintosh runs Snow Leopard, Windows 7 and Ubuntu. The time constantly gets lost after a reboot ((Mac OS always sets it back 4-5 hours! Tell me how to fix the problem

    A problem with time synchronization is relevant not only for Hackintoshes, but also for real Macs, on which Windows runs via Boot Camp. The reason for this is very simple: Mac OS X always assumes that the time recorded in the BIOS (or EFI) is written there in the format UTC- in other words, according to Greenwich. To it she adds the appropriate correction for the time zone.

    But Windows does things differently: it reads directly time from BIOS. And if you change this time, or it is automatically synchronized, then it will be recorded in the BIOS in the corrected format: UTC+correction.

    How to resolve this contradiction? There are two approaches: one from the Mac OS side, the other from the Windows and Linux side.

    Solution using Mac OS X

    Let's say right away that this is not the best way. The bottom line is that for Mac OS X we set the time zone to Greenwich Mean Time. For example, in the settings (remote date and time, tab Timezone) select as your locality Reykjavik.

    In addition, on the tab "Date and time" Be sure to disable automatic time synchronization, otherwise it will turn out even worse than before.

    After these steps, the time in Windows will always be correct, and Mac OS X will not mess it up. But why isn't this the best way? The fact is that if you synchronize some gadget with Mac OS X - for example, an iPhone, then the wrong time zone will distort many important data. For example, the time of incoming SMS will also be Greenwich.

    Solution using Windows and Linux

    Another way is to have Windows and Linux read the time from the BIOS the same way Mac OS does. Fortunately, such an opportunity is indeed provided, but it is hidden very deeply.

    On Windows, you will have to run the program from the Run window regeditRegistry editor. Then go to the thread \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation and create a DWORD value there with the name RealTimeIsUniversal and a value equal to one:

    On Linux (at least on Ubuntu), you need to edit the file /etc/default/rcS in any text editor and replace the contents of the parameter "UTC=no" on "UTC=yes".

    After this, reboot into Mac OS X and set your native time zone, at the same time you can enable automatic time synchronization via the Internet. After rebooting in Windows and Ubuntu you will see exactly the same time.

    Using multiple operating systems on the same computer sometimes causes them to conflict with each other when they use the same thing. Sometimes it concerns something as simple as time. Even such popular PC operating systems as Windows and Ubuntu can not get along and constantly change each other's time to the incorrect one.

    The reasons for this phenomenon are actually simple: Windows perceives the system time (which is displayed in the CMOS settings) as local (taking into account the time zone), and Ubuntu - according to UTC (Greenwich Mean Time, not taking into account the time zone). Because of this, they adjust the system time to suit their logic, violating each other's logic.

    The solution to the problem is also simple: either force Windows to add a time zone offset to the system time, or prevent Ubuntu from adding this offset.

    Settings in Ubuntu

    Starting from version 16.04, time display settings can be switched using two commands.

    Enabling local time display:
    sudo hwclock --localtime --adjust

    Enabling UTC display:
    sudo hwclock --utc --adjust

    In older versions of Ubuntu you need to edit the rtC file:

    sudo nano /etc/default/rcS

    You need to add (to display local time) or remove this line (to display UTC time):

    Settings in Windows

    In Windows, almost all system settings are edited in the registry; TimeZoneInformation, which is necessary in this situation, is no exception. It is located in the registry at this address:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation

    Here you need to add or change the RealTimeIsUniversal parameter. Its type is DWORD. In order for the system time to be read in UTC, you need to set the value to 1; to recognize it as local, you need to set the value to 0 or completely remove this parameter.

    The Registry Editor can be launched using the regedit command.