原因分析
Ubuntu默認是用硬件時間(RTC, real time clock),加上UTC(universal time)時區得到顯示的時間。
而Windows則默認用本地時間(local time),這導致Windows和Ubuntu雙系統的時間顯示不一致。
具體表現:在Windows上通過關掉-開啟網絡同步時區,正確的顯示了時間;重啟進Ubuntu,時間顯示也正確;但再次回到Win10發現時間少了8小時。
解決辦法
方法1:改Ubuntu時間顯示方式
timedatectl set-local-rtc 1 --adjust-system-clock
驗證:
timedatectl
(base) 1080Ti% timedatectl
Local time: 四 2020-05-14 18:52:11 CST
Universal time: 四 2020-05-14 10:52:11 UTC
RTC time: 四 2020-05-14 18:52:12
Time zone: Asia/Shanghai (CST, +0800)
Network time on: yes
NTP synchronized: no
RTC in local TZ: yes
Warning: The system is configured to read the RTC time in the local time zone.
This mode can not be fully supported. It will create various problems
with time zone changes and daylight saving time adjustments. The RTC
time is never updated, it relies on external facilities to maintain it.
If at all possible, use RTC in UTC by calling
'timedatectl set-local-rtc 0'.
然后重啟進入Windows,調整到正確時間。以后再進入Ubuntu或Windows都顯示正確了。
方法2:改Windows注冊表
不推薦這種方式,不過你如果堅持要用,也不妨一試:
管理員方式打開cmd,執行如下命令:
64位系統(目前絕大多數都是64位win10):
Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_QWORD /d 1
32位系統(如果你的電腦情況特殊,用了32位win10,此類情況很少見):
Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1
然后,關掉“網絡更新”的時間選項,並且重啟系統。