大网数据广告活动
服务器运维问答

``date`` in terminal now in 12hr format on Debian Buster

· 52CE 我爱测

Since updating to Debian Buster, running date on the terminal shows the clock in AM/PM format instead of 24hr clock. This is new and is happening on all updated installations. Docker container: yeri@b9b3e889fd76 ~ $ date Thu 01 A…

问题原文

原帖链接 · Tuinslak · CC BY-SA 4.0

Since updating to Debian Buster, running date on the terminal shows the clock in AM/PM format instead of 24hr clock. This is new and is happening on all updated installations.

Docker container:

yeri@b9b3e889fd76 ~ $ date
Thu 01 Aug 2019 11:28:25 PM +08

Native host:

liana ~ # date
Thu 01 Aug 2019 11:32:44 PM +08

Digital Ocean:

ui0 ~ # date
Thu 01 Aug 2019 05:33:11 PM CEST

This is quite annoying and I didn't ask for this -- however can't find the settings to change it.

The only thing I can think of is that the locale is set to US; but that was the case before as well (Debian 9):

ui0 ~ # cat /etc/default/locale 
#  File generated by update-locale
LANG=en_US.UTF-8
yeri@b9b3e889fd76 ~ $ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

yeri@b9b3e889fd76 ~ $ date
Sun 04 Aug 2019 04:39:14 PM +08

yeri@b9b3e889fd76 ~ $ locale date_fmt
%a %d %b %Y %r %Z

yeri@b9b3e889fd76 ~ $ locale -k LC_TIME
abday="Sun;Mon;Tue;Wed;Thu;Fri;Sat"
day="Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday"
abmon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec"
mon="January;February;March;April;May;June;July;August;September;October;November;December"
am_pm="AM;PM"
d_t_fmt="%a %d %b %Y %r %Z"
d_fmt="%m/%d/%Y"
t_fmt="%r"
t_fmt_ampm="%I:%M:%S %p"
era=
era_year=""
era_d_fmt=""
alt_digits=
era_d_t_fmt=""
era_t_fmt=""
time-era-num-entries=0
time-era-entries="S"
week-ndays=7
week-1stday=19971130
week-1stweek=1
first_weekday=1
first_workday=2
cal_direction=1
timezone=""
date_fmt="%a %d %b %Y %r %Z"
time-codeset="UTF-8"
alt_mon="January;February;March;April;May;June;July;August;September;October;November;December"
ab_alt_mon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec"

已采纳解答

原帖链接 · roelvanmeer · CC BY-SA 4.0

It seems the reason for this change is that in buster the en_US locale is updated. Since it is meant to represent US customs, which is to specify time in the 12 hour format, time is now shown as such, even though it may come as a surprise to everyone who has relied on the old behavior.

A solution, as already mentioned by @JosefZ in the comments, is to use a locale that has the time settings that you want, for example C.UTF-8. To make this change permanent on Debian you'd run:

update-locale LC_TIME=C.UTF-8

This sets the definition for LC_TIME in the file /etc/default/locale.

You can find more information about the change itself in Debian bug #877900

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-08-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。