Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I do ls -l I get

-rw-------  1 nifle None  17K Jul 15 01:48 .bash_history
-rwxr-xr-x  1 nifle None 1.2K Feb  9  2010 .bash_profile*
-rwxr-xr-x  1 nifle None 3.7K Mar 22 10:03 .bashrc*
-rwxr-xr-x  1 nifle None 3.7K Feb  9  2010 .bashrc~*
drwxr-xr-x+ 1 nifle None    0 Mar  6 17:31 .cpan/
drwxr-xr-x+ 1 nifle None    0 Jan  3  2011 .emacs.d/
 <snip>

How can I get the date/time format to allways be YYYY-MM-DD HH:MM insted?

share|improve this question
up vote 8 down vote accepted

Assuming GNU ls, from info ls "Formatting file timestamps":

`--time-style=STYLE'
     List timestamps in style STYLE.  The STYLE should be one of the
     following:

...

`long-iso'
      List ISO 8601 date and time in minutes, e.g., `2002-03-30
      23:45'.  These timestamps are shorter than `full-iso'
      timestamps, and are usually good enough for everyday work.
      This style is equivalent to `+%Y-%m-%d %H:%M'.

...

   You can specify the default value of the `--time-style' option with
the environment variable `TIME_STYLE'; if `TIME_STYLE' is not set the
default style is `locale'.

So put the following in your .bashrc or .bash_profile and you are all set:

export TIME_STYLE=long-iso
share|improve this answer
    
Added a little more info to your answer. – Nifle Jul 15 '11 at 14:37
    
This apeared to be dangerous on servers with loads of custom scripts who depend on the output of "ls"... :-( ok, the scripts are wrong indeed.. but be aware of possible consequences – JDC Jul 22 at 7:42
1  

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .