I am having some issues processing dates, where they are being interpreted in US format (mm-dd) instead of EU/AU format (dd-mm). It looks like date isn't respecting my locale settings, or they are set incorrectly.

# This is correct, date read as US mm-dd-yy format
$ LC_TIME="en_US" date +%Y-%m-%d -d 1/2/03

# This is incorrect, dates are read as US mm-dd-yy instead of AU dd-mm-yyyy
$ LC_TIME="en_AU" date +%Y-%m-%d -d 1/2/03

The locale settings seem fine, as date can produce the correct format:

$ LC_TIME="en_US" date +%x -d 2003-02-01
$ LC_TIME="en_AU" date +%x -d 2003-02-01

Is this a bug in date, or do you need to do something else to get it to respect the locale settings when reading short dates?


GNU date -d option is expecting the provided date to be in "locale independent format", i.e. POSIX which essentially means US format as far as xx/yy/zz dates are concerned.

| improve this answer | |
  • Shame. Any way to get it to read dates in all the various fancy formats but in dd/mm arrangement instead, without resorting to regexes? The dates I am trying to process vary somewhat and date can recognise them all, but gets the month and day the wrong way around (or reports them as invalid when the "month" is larger than 12). – Malvineous Aug 16 '15 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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