参照 https://wiki.archlinux.org/title/System_time

1.使用命令查看时间

timedatectl

显示类似

               Local time: Wed 2024-01-10 14:39:40 GMT
       	   Universal time: Wed 2024-01-10 14:39:40 UTC
             	 RTC time: Wed 2024-01-10 14:39:40
            	Time zone: Europe/London (GMT, +0000)
System clock synchronized: no
              NTP service: inactive
      	  RTC in local TZ: no

解析
Time zone是时区

Local time显示本地时间,一般是系统桌面的时间,GMT是某地时间
本地时间等于世界时间加时区值,时区值是上面+0000部分

Universal time显示世界时间,也就是0时区时间,如英国地区时间

RTC time显示真实时间,也就是主板时间

date

显示本地时间

2.如果世界时间不是0时区时间,那么时区所对应的时间就会不正确

3.解决办法
ntp(Network Time Protocol)是一种用于在计算机网络中同步时间的协议。它允许计算机和其他设备通过互联网或局域网获取准确的时间信息,并将其与本地时钟进行同步

安装ntp:

sudo pacman -S ntp

从网站同步时间:

sudo ntpdate pool.ntp.org

Universal time世界时间Local time本地时间就会设置正确

列出时区:

timedatectl list-timezones 

选择时区:

timedatectl set-timezone Europe/London	

把主板时间同步为本地时间:

sudo timedatectl set-local-rtc 1

再timedatectl的话会出现警告

Warning: The system is configured to read the RTC time in the local time zone.
     This mode cannot 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'.

所以再

sudo timedatectl set-local-rtc 0