自建服务都搬到了新vps上,今天我才发现vps上的时区不对,于是用中文在谷歌里搜索相关问题,出来的结果不是csdn就是博客园,里面教的方法是修改LANG选项,比如改成中文,这明显走了弯路,我要修改的是时间,和语言毫无关系,所以我又换英文在谷歌里搜索,这次出来的质量要高很多,第一位就是askubuntu。不得不说计算机方面的资料还是英文更加齐全,这里记录一下修改方法:

# 设置时区

sudo timedatectl set-timezone Asia/Shanghai

# 设置时间格式

sudo localectl set-locale LC_TIME="en_GB.UTF-8"

除此之外,askubuntu还介绍了一种修改时间格式的方法,这里也原文搬运:

Alternatively, you can customize date and time formatting in locale definition file /usr/share/i18n/locales/en_US. You will find date and time formatting in the following section:

% Appropriate date and time representation (%c)

d_t_fmt "%a %d %b %Y %r %Z"

%

% Appropriate date representation (%x)

d_fmt   "%m//%d//%Y"

%

% Appropriate time representation (%X)

t_fmt   "%r"

%

% Appropriate AM/PM time representation (%r)

t_fmt_ampm "%I:%M:%S %p"

%

% Appropriate date and time representation for date(1)

date_fmt "%a %d %b %Y %r %Z"

In this case, to get 24h clock, you have to replace %r to %T and run locale-gen to regenerate locales. 来源链接:传送门