博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何修复Windows和Linux在双启动时显示不同的时间
阅读量:2510 次
发布时间:2019-05-11

本文共 8876 字,大约阅读时间需要 29 分钟。

Your computer stores the time in a hardware clock on its motherboard. The clock keeps track of time, even when the computer is off. By default, Windows assumes the time is stored in local time, while Linux assumes the time is stored in UTC time and applies an offset. This leads to one of your operating systems showing the wrong time in a .

您的计算机将时间存储在主板上的硬件时钟中。 即使计算机关闭,时钟也会跟踪时间。 默认情况下,Windows假定时间以本地时间存储,而Linux假定时间以UTC时间存储并应用偏移量。 这会导致您的操作系统之一在显示错误的时间。

To fix this, you have two options: Make Linux use local time, or make Windows use UTC time. Don’t follow both steps of instructions or they still won’t be speaking the same language! We recommend you make Linux use local time, if possible.

要解决此问题,您有两个选择:使Linux使用本地时间,或使Windows使用UTC时间。 不要遵循这两个指示步骤,否则它们仍然不会说相同的语言! 如果可能,我们建议您使Linux使用本地时间。

选项一:使Linux使用本地时间 (Option One: Make Linux Use Local Time)

Making Linux use local time the same way Windows does is probably the best option. Windows does have a registry setting that forces it to store the time as UTC, but it reportedly isn’t well supported and can cause problems with some third-party applications that always assume the hardware clock is in local time. It’s also incompatible with Windows’ own Internet time-syncing service.

使Linux使用与Windows相同的本地时间可能是最好的选择。 Windows确实有一个注册表设置,强制其将时间存储为UTC,但是据报道它没有得到很好的支持,并且可能会导致某些总是假定硬件时钟在本地时间的第三方应用程序出现问题。 它也与Windows自己的Internet时间同步服务不兼容。

The steps to make your Linux system use local time can vary from Linux distribution to Linux distribution. However, on any Linux distribution with , you can use the timedatectl command to make this change. This will work on modern versions of Ubuntu, Fedora, Red Hat, Debian, Mint, and other Linux distributions that use systemd.

使Linux系统使用本地时间的步骤因Linux发行版而异。 但是,在任何带有 Linux发行 ,都可以使用timedatectl命令进行更改。 这将适用于现代版本的Ubuntu,Fedora,Red Hat,Debian,Mint和其他使用systemd的Linux发行版。

To make this change, first open a Terminal window on your Linux system. Run the following command to put the real time clock on the motherboard into local time. Linux will store the time in local time, just like Windows does.

要进行此更改,请首先在Linux系统上打开“终端”窗口。 运行以下命令,将主板上的实时时钟设为本地时间。 就像Windows一样,Linux会将时间存储在本地时间。

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

To check your current settings, run:

要检查当前设置,请运行:

timedatectl

If you see “RTC in local TZ: yes”, Linux is set to use the local time zone instead of UTC. The command warns you that this mode is not fully supported and can cause some problems when changing between time zones and with daylight savings time. However, this mode is probably better supported than the UTC option in Windows. If you dual-boot with Windows, Windows will handle daylight savings time for you.

如果您看到“本地TZ中的RTC:是”,则Linux已设置为使用本地时区而不是UTC。 该命令警告您此模式不受完全支持,并且在时区之间和夏时制之间切换时可能会引起一些问题。 但是,此模式可能比Windows中的UTC选项更好地支持。 如果您使用Windows双重引导,则Windows将为您处理夏令时。

If you ever want to undo this change, run the following command:

如果要撤消此更改,请运行以下命令:

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

选项二:使Windows使用UTC时间 (Option Two: Make Windows Use UTC Time)

Making Windows use UTC time like Linux is probably not the best option. You can edit the registry to make Windows use UTC time, but this could potentially cause more problems than just making Linux use local time.

使Windows像Linux一样使用UTC时间可能不是最佳选择。 您可以编辑注册表以使Windows使用UTC时间,但这可能会导致比仅使Linux使用本地时间更多的问题。

If you do want to do this, you’ll first want to disable the Internet time updating feature on Windows. This ensures Windows won’t set the clock incorrectly when trying to sync the current time from the Internet. On Windows 10, head to Settings > Time & language and disable “Set time automatically”. On Windows 7, right-click the system clock in the taskbar and select “Adjust date/time”. Click the “Internet Time” tab, click the “Change Settings” button, uncheck the “Synchronize with an Internet time server” option, and click “OK”.

如果确实要执行此操作,则首先要在Windows上禁用Internet时间更新功能。 这样可以确保Windows在尝试从Internet同步当前时间时不会错误地设置时钟。 在Windows 10上,转到“设置”>“时间和语言”,然后禁用“自动设置时间”。 在Windows 7上,右键单击任务栏中的系统时钟,然后选择“调整日期/时间”。 单击“ Internet时间”选项卡,单击“更改设置”按钮,取消选中“与Internet时间服务器同步”选项,然后单击“确定”。

通过编辑注册表使Windows使用UTC时间 (Make Windows Use UTC Time By Editing the Registry)

You will now need to add the appropriate value to the Windows registry. Here’s our standard warning: The Registry Editor is a powerful tool and misusing it can render your system unstable or even inoperable. This is a pretty easy hack and you shouldn’t have any problems as long as you follow the instructions. That said, if you’ve never worked with it before, consider reading about  before you get started. And definitely  (and !) before making changes.

现在,您需要将适当的值添加到Windows注册表中。 这是我们的标准警告:注册表编辑器是一个功能强大的工具,滥用它会使您的系统不稳定甚至无法运行。 这是一个非常简单的技巧,只要按照说明进行操作,就不会有任何问题。 也就是说,如果您以前从未使用过它,请在开始之前考虑阅读有关 。 并在进行更改之前一定要 (和 !)。

First, open the Registry Editor by clicking Start, typing “regedit”, and pressing Enter. Agree to the security prompt that appears.

首先,通过单击开始,键入“ regedit”,然后按Enter打开注册表编辑器。 同意出现的安全提示。

Navigate to the following key in the left pane of the registry editor:

导航到注册表编辑器左窗格中的以下项:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation

On the latest versions of Windows 10, you can copy and paste the above line into the address box. However, this hack will work on Windows 7 as well.

在Windows 10的最新版本上,您可以复制以上行并将其粘贴到地址框中。 但是,此hack也可以在Windows 7上运行。

Right-click the “TimeZoneInformation” key and select New > DWORD (32-bit) Value.

右键单击“ TimeZoneInformation”键,然后选择“新建”>“ DWORD(32位)值”。

Name your new value RealTimeIsUniversal.

将新值命名为RealTimeIsUniversal

Double-click the RealTimeIsUniversal value you just created, set is value data to 1, and click “OK”.

双击刚创建的RealTimeIsUniversal值,将value数据设置为1 ,然后单击“确定”。

You’re now done, and you can close the Registry Editor. Windows will store the time in UTC, just like Linux does.

现在,您已经完成,可以关闭注册表编辑器。 Windows会像Linux一样将时间存储在UTC中。

If you ever want to undo this change, return to this location in the registry, right-click the RealTimeIsUniversal value you added, and delete it from your registry.

如果要撤消此更改,请返回到注册表中的该位置,右键单击添加的RealTimeIsUniversal值,然后将其从注册表中删除。

下载我们的一键式注册表黑客 (Download Our One-Click Registry Hack)

If you don’t want to edit the registry yourself, you can use our downloadable registry hack. We created one hack that makes Windows use UTC time, and one that restores it to local time. Both are included in the following ZIP file. Just download the file, double-click the hack you want to use, and agree to add the information to your registry.

如果您不想自己编辑注册表,则可以使用我们的可下载注册表黑客。 我们创建了一种使Windows使用UTC时间的黑客,并且将其还原到本地时间。 两者都包含在以下ZIP文件中。 只需下载文件,双击要使用的hack,然后同意将信息添加到注册表即可。

The above hacks do the same thing we described above. The Make Windows Use UTC Time hack creates the “RealTimeIsUniversal” entry with a value of “1”, while the Make Windows Use Local Time hack deletes the “RealTimeIsUniversal” entry.

上面的骇客所做的与我们上面描述的相同。 “使Windows使用UTC时间” hack创建一个值为“ 1”的“ RealTimeIsUniversal”条目,而使Windows“使用本地时间” hack删除“ RealTimeIsUniversal”条目。

If you ever want to see what this or any other .reg file does, right-click it and select “Edit” to view the file in Notepad. You can easily make your own registry hacks, which just consist of a list of registry entries to add, edit, and remove in a properly formatted list.

如果您想查看此文件或任何其他.reg文件的功能,请右键单击该文件,然后选择“编辑”以在记事本中查看该文件。 您可以轻松地进行自己的注册表修改,其中仅包含要在正确格式的列表中添加,编辑和删除的注册表项列表。

在Mac上双启动Windows怎么办? (What About Dual-Booting Windows on a Mac?)

Although Apple’s macOS uses UTC time like Linux does, you shouldn’t have to do anything special when . Apple’s Boot Camp drivers handle everything. (Hackintosh dual-booters are another story, though, and will have to try using the Windows registry tweak above.)

尽管Apple的macOS像Linux一样使用UTC时间,但是时,您不必做任何特殊的事情。 苹果公司的Boot Camp驱动程序可以处理所有问题。 (不过,Hackintosh双重引导程序是另一回事,必须尝试使用​​上面的Windows注册表调整项。)



If you’re wondering why Windows uses local time instead of UTC like other operating systems, official Microsoft blog . In short, it was to preserve backwards compatibility with  systems and to prevent people from getting confused when they set the time in the computer’s BIOS. Of course, PC manufacturers chose local time to be compatible with Windows and Windows chose local time to be compatible with the decision PC manufacturers chose, so the cycle became self-reinforcing.

如果您想知道Windows为什么像其他操作系统那样使用本地时间而不是UTC,请在Microsoft官方博客 。 简而言之,这是为了保持与系统的向后兼容性,并防止人们在计算机的BIOS中设置时间时感到困惑。 当然,PC制造商选择本地时间与Windows兼容,而Windows选择本地时间与PC制造商选择的决定兼容,因此周期变成了自我强化。

There’s currently no standard for labeling whether a time is stored as UTC or local time in BIOS or UEFI firmware, which would probably be the most logical solution. But it would require some work, and most people will never even notice different operating systems use different time formats—except in dual-boot configurations.

当前尚无用于标记时间是存储在BIOS还是UEFI固件中的UTC或本地时间的标准,这可能是最合乎逻辑的解决方案。 但这需要一些工作,并且大多数人甚至都不会注意到不同的操作系统使用不同的时间格式(双引导配置除外)。

翻译自:

转载地址:http://bmzwd.baihongyu.com/

你可能感兴趣的文章
js的JSON对象
查看>>
做北京项目的过程所得
查看>>
PHP模拟post提交数据方法汇总
查看>>
windows环境libevent搭建和demo分析
查看>>
Javascript通过bind()掌控this
查看>>
JavaWeb_JSTL标签数据的存储
查看>>
linux 常见问题
查看>>
Android相机实时自动对焦的完美实现
查看>>
OpenCV入门笔记(七) 文字区域的提取
查看>>
flask中的上下文处理器context_processor
查看>>
项目中的一个分页功能pagination
查看>>
[GraphQL] Use Arguments in a GraphQL Query
查看>>
[React] Pass Data To Event Handlers with Partial Function Application
查看>>
SEO怎么去发布外链?
查看>>
c#基础学习(0703)之string.Format格式化日期
查看>>
成绩分配
查看>>
BZOJ3667: Rabin-Miller算法
查看>>
查找目录下的文件
查看>>
博客文章通知
查看>>
gcc悄无声色将静态函数内联了
查看>>