参照 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
分类:
linux
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理