[CentOS7]サーバのタイムゾーンの設定


サーバの初期設定はUTCの設定になっているので、日本時間にする場合以下のコマンドを実行します。

<変更前>

# timedatectl
Local time: Sat 2019-11-23 01:12:28 UTC
Universal time: Sat 2019-11-23 01:12:28 UTC
RTC time: Sat 2019-11-23 01:12:22
Time zone: UTC (UTC, +0000)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a

<日本時間へ変更>

# timedatectl set-timezone Asia/Tokyo

<変更後>

# timedatectl
Local time: Sat 2019-11-23 10:23:47 JST
Universal time: Sat 2019-11-23 01:23:47 UTC
RTC time: Sat 2019-11-23 01:23:41
Time zone: Asia/Tokyo (JST, +0900)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a

設定可能なタイムゾーンを表示

# timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa

タイムゾーンファイルの置き場所

# cd /usr/share/zoneinfo/
[root@ip-10-150-9-70 zoneinfo]# ll
total 392
drwxr-xr-x 2 root root 4096 Mar 5 2019 Africa
drwxr-xr-x 6 root root 8192 Mar 5 2019 America
drwxr-xr-x 2 root root 187 Mar 5 2019 Antarctica

※ファイルの中身を書き換えるとPHPの時間処理(Datetimeクラスなど)に影響が出るため慎重に検討する必要があります。