[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Output from date command defaults to 12-hour in Buster.



On Tue, Apr 28, 2020 at 08:36:11PM -0500, Martin McCormick wrote:
> In every flavor of unix I have used since I began learning unix
> in 1989, the date command would produce a string containing the
> current time in 24-hour format
> similar to
> 
> Tue Apr 28 20:25:11 CDT 2020
> 
> 	If you run the date command in buster, you get
> 
> Tue 28 Apr 2020 08:26:24 PM CDT
> 
> 	One can cause date to run in 24-hour format but you have
> to run date as follows:
> 
> date +"%a %b %d %T %Z %Y"
> 
> 	Some people have set their locale to British English and
> now get the older-style 24-hour date format but setting the
> locale is kind of an extreme way to do things.
> 
> 	Is there any environment variable or local configuration
> variable which will make date produce the 24-hour time stamp
> similar to past implementations of date?
> 

You probably have LANG set, but it seems you might already know that.

roberto@miami:~$ echo $LANG
en_US.utf8
roberto@miami:~$ date
Tue 28 Apr 2020 09:41:33 PM EDT
roberto@miami:~$ LC_TIME=C date
Tue Apr 28 21:41:37 EDT 2020

Since the convention in the US is to use AM/PM, it stands to reason that
setting the locale will produce a conventional date format for the
locale.  Note the folling from the locale(7) man page:

       LC_TIME
              This category governs the formatting used for date and
              time values.  For example, most of Europe uses a 24-hour
              clock versus the 12-hour clock used in the United States.
              The setting of this category affects the behavior of
              functions such as strftime(3) and strptime(3).

Regards,

-Roberto

-- 
Roberto C. Sánchez


Reply to: