How can I get the ls command to show an exact time?
4 Answers
Might depend on your distro, 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 localetry
man ls from your command line
2As well as CaseyIT's solution, you can also use the --full-time option.
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 -lfiles 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).
In FreeBSD the -T flag does this
ls -alFT
-rwxrwxr-x 1 un un 4900 May 5 10:52:03 2013 custom-banner.js*