Linux 更改CentOS 7中的时区显示
我有一个愚蠢的问题,那就是如何将CentOS 7中的日期时间从2020年6月4日20:30:43的格式更改为2020年6月4日20:33:43+07的格式。这可能吗?顺便说一下,我在安装CentOS 7时使用了timedatectlLinux 更改CentOS 7中的时区显示,linux,centos,timezone,centos7,Linux,Centos,Timezone,Centos7,我有一个愚蠢的问题,那就是如何将CentOS 7中的日期时间从2020年6月4日20:30:43的格式更改为2020年6月4日20:33:43+07的格式。这可能吗?顺便说一下,我在安装CentOS 7时使用了timedatectl # date Thu Jun 4 20:36:46 WIB 2020 改为 # date Thu Jun 4 20:36:46 +07 2020 非常感谢您的帮助。检查shell的当前区域设置: locale 然后从/usr/share/i18n/loca
# date
Thu Jun 4 20:36:46 WIB 2020
改为
# date
Thu Jun 4 20:36:46 +07 2020
非常感谢您的帮助。检查shell的当前区域设置:
locale
然后从/usr/share/i18n/locales/$YOUR\u LOCALE\u此处
文件中相应地编辑date\u fmt
变量。在这种情况下:
date_fmt "+%a %b %e %H:%M:%S %:z %Y"
并在更改后重新生成本地化文件:
locale-gen
如图所示,默认情况下仅支持以下时区格式:
%z +hhmm numeric time zone (e.g., -0400)
%:z +hh:mm numeric time zone (e.g., -04:00)
%::z +hh:mm:ss numeric time zone (e.g., -04:00:00)
%:::z numeric time zone with : to necessary precision (e.g., -04, +05:30)
%Z alphabetic time zone abbreviation (e.g., EDT)
这意味着上一个命令将返回以下内容:
Thu Jun 4 20:22:47 +02:00 2020
但是,您始终可以为日期
命令定义一个自定义别名
,以准确显示您想要的:
alias date='date "+%a %b %e %H:%M:%S %:z %Y" |sed "s|:00||"'
将它添加到您的.bashrc
文件或存储别名的任何位置,您应该会没事的