Skip to main content

Date / Time

Date

Display date

date [-u|--utc]

Set date / time

timedatectl set-time [<YYYY>-<MM>-<DD>] [<HH>:<MM>:<SS>]
date [-u|--utc] <MMDDhhmm[YYYY][.ss]>
date -s "YYYY-MM-DD hh:mm:ss"

Timezone

Display timezone

date "+%Z %z"
cat /etc/timezone

Set timezone

tzselect
timedatectl set-timezone <timezone>

RTC

Real-Time Clock

Set RTC as the local time

timedatectl set-local-rtc { true | t | yes | y | 1 }

Set RTC as the UTC (Coordinated Universal Time)

timedatectl set-local-rtc { false | f | no | n | 0 }

Convert timestamp to date time

# -d <string>  顯示 <string> 所描述的時間
date -d @<timestamp>

Sync Time

Force sync time

service ntpd stop
ntpd -gq
service ntpd start