Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I would like to globally set the Linux date format to ISO, which looks roughly like this:

YYYY-MM-DD HH:MM:SS
2009-03-16 15:20:00

With varying levels of detail, such as omitting time, seconds, etc.

I know that for some applications, you can configure this manually, but I'd like it to be automatically set for every program.

I'm specifically using Ubuntu Intrepid, but a general solution that would work across all distributions would be best.

share|improve this question

5 Answers 5

Set your locale date environment variable LC_TIME to "en_DK" Set it in your .bashrc or similar, or check man locale for how to set it system-wide.

On ArchLinux all of the Locale settings are in /etc/rc.conf and customisations are set up in /etc/rc.local

#!/bin/bash
# Local multi-user startup script
export LC_TIME="en_DK"
share|improve this answer
    
I found that nowadays (Ubuntu 12.04) you need to set it to "en_DK.UTF8", but otherwise, great to know that Danish folks use sane ISO date format ;-). –  pfalcon Aug 24 '13 at 19:22
    
@pfalcon it is not "english in Denmark" as the abbreviations would make one believe, it is mock, which name is a joke that is lost to me... see the references from this freebsd bug, which unfortunately decided not to adopt it: freebsd.org/cgi/query-pr.cgi?pr=137870 that said, it may be very well that in Denmark everyone uses the ISO date formate tho. –  gcb Feb 12 at 8:28
up vote 3 down vote accepted

It's explained at length in this guide: http://ccollins.wordpress.com/2009/01/06/how-to-change-date-formats-on-ubuntu/

share|improve this answer
    
I went and found the link since prestiginate said he couldn't post hyperlinks. And I actually had been there before, but I guess I never bothered doing it on this machine, making me think whatever I tried before didn't work. –  Neil Jun 1 '09 at 21:18

Some people would advise to change your local to german "en_DK" this kind of works if you don't mind the day and month names being in german. Since I cannot post hyperlinks,and this board sees my linux commands as hyperlinks.... (nice one)... I can only say you search (google) how-to-change-date-formats-on-ubuntu and click the first link.

share|improve this answer
    
He meant this link: ccollins.wordpress.com/2009/01/06/… –  Neil Jun 1 '09 at 21:16
    
en_DK is not the German locale either, it's danish. –  GodEater Jun 2 '09 at 7:08
    
it is neither. "en" is English. the "DK" part is the country which sets things like currency symbols, date formats and decimal separators, etc. The first part is the language, which would determine month names. –  gcb Feb 12 at 8:30

Probably the best way to do this, but not break things is to follow the walkthrough at

http://ccollins.wordpress.com/2009/01/06/how-to-change-date-formats-on-ubuntu/

share|improve this answer

Open locale.conf with your editor

# $EDITOR /etc/locale.conf

and insert the line

TIME_STYLE=iso

after saving the file run

# locale-gen
# env-update && source /etc/profile

and test the result

# ls -al /home
drwxr-xr-x   8 root             root      4096 2011-12-2  .
...
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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