查看当前系统时间

1
2
[root@iZ2ze8qtvejt7fnrilbnz6Z ~]# date
2021年 10月 12日 星期二 14:35:00 CST

查看当前时区

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@iZ2ze8qtvejt7fnrilbnz6Z ~]# timedatectl status
Local time: 二 2021-10-12 14:35:34 CST
Universal time: 二 2021-10-12 06:35:34 UTC
RTC time: 二 2021-10-12 14:35:33
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: no
NTP synchronized: yes
RTC in local TZ: yes
DST active: n/a

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'.

修改时间

1
2
[root@iZ2ze8qtvejt7fnrilbnz6Z ~]# date -s "2021-10-12 20:13:00"
2021年 10月 12日 星期二 20:13:00 CST

修改时区

1
timedatectl set-timezone Asia/Shanghai

查看硬件时间

1
2
[root@iZ2ze8qtvejt7fnrilbnz6Z ~]# hwclock --show
2021年10月12日 星期二 14时37分44秒 -0.223697 秒

同步系统时间和硬件时间

1
hwclock --hctosys