设置时区问题
ubuntu系统时区命令 timedatectl
root@grant:/usr/share/zoneinfo/Asia# timedatectl status Local time: Tue 2025-04-08 02:08:10 UTC Universal time: Tue 2025-04-08 02:08:10 UTC RTC time: Tue 2025-04-08 02:08:11 Time zone: Etc/UTC (UTC, +0000) System clock synchronized: yes NTP service: active RTC in local TZ: no
查看可用时区 timedatectl list-timezones
修改时区 timedatectl set-timezone Asia/Shanghai
root@grant:/usr/share/zoneinfo/Asia# timedatectl Local time: Tue 2025-04-08 10:11:03 CST Universal time: Tue 2025-04-08 02:11:03 UTC RTC time: Tue 2025-04-08 02:11:04 Time zone: Asia/Shanghai (CST, +0800) System clock synchronized: yes NTP service: active RTC in local TZ: no
修改mysql时区
SHOW VARIABLES LIKE '%time_zone%'; SET GLOBAL time_zone = 'Asia/Shanghai'; SET SESSION time_zone = 'Asia/Shanghai';
修改docker部署应用时区Dockerfile文件
FROM openjdk:17-jdk # 设置时区为 Asia/Shanghai RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone