How can I get the ls command to show an exact time?

link|improve this question

64% accept rate
feedback

3 Answers

up vote 1 down vote accepted

Might depend on your disrto, but this argument for ls is available in Debian:

--time-style=STYLE
          with -l, show times using style STYLE: full-iso, long-iso,  iso,
          locale,  +FORMAT.   FORMAT is interpreted like `date'; if FORMAT
          is FORMAT1<newline>FORMAT2, FORMAT1 applies to non-recent  files
          and FORMAT2 to recent files; if STYLE is prefixed with `posix-',
          STYLE takes effect only outside the POSIX locale

try

man ls 

in from your command line

link|improve this answer
Superuser is easier than man. Thanks :) – ripper234 Oct 28 '10 at 11:44
--time-style and --full-time are specific to GNU ls, so they're available on every Linux (except some embedded distributions) and few other unices. – Gilles Oct 28 '10 at 23:41
feedback

As well as CaseyIT's solution, you can also use the --full-time option.

link|improve this answer
feedback

Your locale will affect the way ls displays that date and time.

My locale is en_US.UTF-8 and ls always displays hours and minutes when I use ls -l, for example. However, if I change my locale like this:

LC_TIME=C ls -l

files that are newer than six months old don't show a year, older than six months or are in the future don't display a time at all and do show the year. The C locale (aka the POSIX locale) reproduces the historical behavior of ls in this regard (I seem to recall that there were some additional subtleties, however).

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.