LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-16-2021, 09:40 AM   #1
bg368
Member
 
Registered: Nov 2006
Location: USA
Distribution: Debian
Posts: 42

Rep: Reputation: 11
change system-wide date format


The 'date' command on my system is formatted to show the results as: Fri 16 Apr 20 21 10:26:01 AM EDT.
Since the date command is so versatile I wonder if it is possible to change the way dates and times show up in various commands such as 'ls' and the like.
I assume it would be to change the LC_TIME parameter system wide, but I cannot find where it is originally set. Any help is very much appreciated
 
Old 04-16-2021, 09:44 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,876
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
I don't know the answer either, but as opposed to any assumption surrounding LC_TIME, perhaps instead give the source for 'ls' or another command concerned a quick look and determine how it processes the date/time for the output it generates. Because if it is a property, then great.
 
Old 04-16-2021, 10:07 AM   #3
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,327

Rep: Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481
"man date" gives lots of formatting information, and if you want the display to be formatted different than the default it should be easy to design a format that satisfies you then make it an alias for your user so it always displays the way you wish. The alias could be put into ~/.bashrc if you are using bash.
My default display, using fedora is
"Fri Apr 16 10:01:51 AM CDT 2021"

Using an alias means you would not have to mess with the default config.
 
Old 04-16-2021, 10:19 AM   #4
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
1) /etc/default/locale. Changed by update-locale.

2) /etc/locale.conf. Changed by localectl.

3) localehelper from the eponymous package. Used like this:
Code:
localehelper LANG=C -- ls -l
4) If the locale in question is already configured (e.g. sudo dpkg-reconfigure locales) then this does much the same:
Code:
LC_ALL=C ls -l

Last edited by shruggy; 04-16-2021 at 10:38 AM.
 
1 members found this post helpful.
Old 04-16-2021, 10:38 AM   #5
bg368
Member
 
Registered: Nov 2006
Location: USA
Distribution: Debian
Posts: 42

Original Poster
Rep: Reputation: 11
Thanks, Shruggy. That oughta do it.
 
Old 04-16-2021, 10:47 AM   #6
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,327

Rep: Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481
This is strange.
on my system I see that /etc/locales.conf gives the following for the default and en_US locales.
Code:
[default]
        date format = %b %e %Y %I:%M:%S:%z%p

[en_US]
        date format = %b %e %Y %I:%M:%S:%z%p
        language = us_english
        charset = iso_1
Both those are identical, and my locale is en_US but the date command gives
"Fri Apr 16 10:01:51 AM CDT 2021"
So the config for the date displayed does not match the formatting given in that config file.
 
Old 04-16-2021, 12:14 PM   #7
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
@computersavvy. locales.conf is different from locale.conf. I meant the latter.
 
Old 04-16-2021, 01:49 PM   #8
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,327

Rep: Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481Reputation: 1481
On my system I have both, and the locale.conf only lists the language for the locale (LANG="en_US.UTF-8")

Obviously a difference in the way different distros are configured.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Emergency! Change the system wide file-max, then occur Too many open files in system hstk Linux - General 2 06-17-2019 03:24 AM
Unable to subtract current date and future date in YYYY-MM-DD format archie7 Linux - Newbie 11 05-11-2018 03:29 AM
[SOLVED] Converting date feed into different date format keif Programming 5 07-08-2014 08:39 AM
LXer: How to change Thunderbird's date format in Date column LXer Syndicated Linux News 0 07-18-2012 02:11 AM
Trying to decide on a LCD monitor - 20", 20" wide, or 22" wide? etcetera General 5 07-28-2008 01:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration