跳至主要内容

如何在 Ubuntu 上更改時區為本地時間

· 2 分鐘閱讀
Eric Cheng
Eric Cheng
JAVA 後端工程師

在雲端新建一台 VM 時,預設時區通常會是 UTC,和習慣 Local 時間是不一樣的,以台北時間來說就會差八個小時,簡單記錄一下怎麼修改時區

查詢時間

timedatectl

這時會看到像這樣的結果

               Local time: Mon 2025-02-10 01:19:25 UTC
Universal time: Mon 2025-02-10 01:19:25 UTC
RTC time: Mon 2025-02-10 01:19:25
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no

列出所有可用時區,查詢台北時間的名稱

timedatectl list-timezones ## 列出全部時區
timedatectl list-timezones | grep Taipei ## 列出台北時區

會看到結果如下

Asia/Taipei

執行

sudo timedatectl set-timezone Asia/Taipei

重新查詢時間

timedatectl

重新得到結果

               Local time: Mon 2025-02-10 09:20:09 CST
Universal time: Mon 2025-02-10 01:20:09 UTC
RTC time: Mon 2025-02-10 01:20:09
Time zone: Asia/Taipei (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no

就可以看到 Time zone 更改為 Asia/Taipei (CST, +0800),Local time 也成功更改為台北時間了



版權聲明

,轉載請註明出處
本文連結: https://tech.havocfuture.tw/blog/ubuntu-set-timezone



這是 google 廣告