检查你的 shell 的当前语言环境:
locale
然后根据您的文件编辑/usr/share/i18n/locales/$YOUR_LOCALE_HERE 文件中的date_fmt 变量。在这种情况下:
date_fmt "+%a %b %e %H:%M:%S %:z %Y"
并在更改后再次重建您的本地化文件:
locale-gen
正如date man page 中所见,默认情况下似乎只支持以下时区格式:
%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
但是,您始终可以为您的 date 命令定义一个自定义 alias 以完全按照您的意愿显示:
alias date='date "+%a %b %e %H:%M:%S %:z %Y" |sed "s|:00||"'
将其添加到您的 .bashrc 文件或您存储别名的任何位置,您应该没问题。