[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 10:53:25PM -0600, Charles Curley wrote:
> Adding
> 
> alias date='date +"%a %b %d %T %Z %Y"'
> 
> to one's .bashrc or /etc/bashrc should get the OP what he wants.

No, this is not a viable solution.  It will completely hinder your
ability to use date with other format arguments, and it will not
address the underlying problem, which is in the locale definition used
by strftime(3) and similar pieces of libc.  (There are other programs
that are affected by this, not just date(1).)

Setting LC_TIME=C is a much better answer.


unicorn:~$ locale | grep -v \"$
LANG=en_US.utf8
LANGUAGE=
LC_ALL=
unicorn:~$ date
Wed 29 Apr 2020 07:43:23 AM EDT
unicorn:~$ export LC_TIME=C
unicorn:~$ date
Wed Apr 29 07:44:00 EDT 2020


unicorn:~$ unset LC_TIME
unicorn:~$ printf '%()T\n' -1
07:45:12 AM
unicorn:~$ export LC_TIME=C
unicorn:~$ printf '%()T\n' -1
07:45:31


And so on.


Reply to: