date format on terminal with ls -l

Joined
Jun 16, 2014
Messages
4
Reaction score
0
Points
1
Anybody knows how to change the date format when invoking "ls -l " on the command terminal?
Currently I get Month Day Year and I want YEAR-MM-DD format including those dashes. And
it is not with the locale. I use en.US-UTF8 in linux and it does prints it the way I want it to be, so I don't need to change it to ISO.
I have seen other forum comments about it but not much and they do not solve the problem.
Any thoughts?
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
You get the year? Mine only shows month/day. Screen shot?
 
OP
A
Joined
Jun 16, 2014
Messages
4
Reaction score
0
Points
1
Hi cradom, yes, it shows the year whenever it is not the current year, in which case it shows the time. Here is a screen shot of two systems; the first on a mac and the other on my linux box. The mac shows the date format i do not want and the second is the linux showing the format I wish to have on the mac.
commandlinedateformat.png
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
Ummm...what screen shots?
Checked a few things. Mine does it too. Never noticed that before. Never really looked.
Don't know how to change time format but...
The -U switch will list according to file creation date
The -t switch will list according to file modification date
Maybe that will help?
 
OP
A
Joined
Jun 16, 2014
Messages
4
Reaction score
0
Points
1
Hmm...this is really strange. I can't believe there is no answer. Perhaps it is simple, but would love someone to point me in the right direction....
 
Joined
Nov 14, 2009
Messages
20
Reaction score
0
Points
1
Location
Shenzhen China
Your Mac's Specs
iMac 27 @ 3.5 GHz
Is the format you want a standard format from a particular region?
If so, go into Sys Pref in Language and Region and set the date format to the region you need.
 
Joined
Jul 2, 2007
Messages
3,494
Reaction score
204
Points
63
Location
Going Galt...
Your Mac's Specs
MacBookAir5,2:10.13.6-iMac18,3:10.13.6-iPhone9,3:11.4.1
stat -l -t '%FT%T' * for example.
 
Joined
Oct 16, 2010
Messages
18,150
Reaction score
1,899
Points
113
Location
Brentwood Bay, BC, Canada
Your Mac's Specs
2020 27" i9 5K nano iMac, 1TB(partitioned) SSD, GB, macOS 15.3.1 Sequoia
Gheese XJ-linux, for a second or so I thought you were just swearing at the OP!! ;D
 

chscag

Well-known member
Staff member
Admin
Joined
Jan 23, 2008
Messages
65,246
Reaction score
1,834
Points
113
Location
Keller, Texas
Your Mac's Specs
2017 27" iMac, 10.5" iPad Pro, iPhone 8, iPhone 11, iPhone 12 Mini, Numerous iPods, Monterey
Gheese XJ-linux, for a second or so I thought you were just swearing at the OP!! ;D

He was, it's called Unix speak. :p
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
Is the format you want a standard format from a particular region?
If so, go into Sys Pref in Language and Region and set the date format to the region you need.
I tried that, first thing I thought of. Couldn't get it to work.
Or is a restart required?
 
OP
A
Joined
Jun 16, 2014
Messages
4
Reaction score
0
Points
1
Thanks guys, but I am trying to look for the cause for the discrepancy, not looking for a way to go around it. I tried setting the locale, but as I stated before, that is not the culprit. Neither is changing it on the System Preferences. I have tried that as well to no avail.
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
According to man date:
The command:

date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S"

will display:

DATE: 1987-11-21
TIME: 13:36:16

So maybe you could do something with the env command to set a default date readout? Or possibly an alias or function?
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top