0

I have just installed ubuntu server 19.10. When I enter the date command I get the following output

Sun 10 Nov 2019 05:16:05 PM AEDT

My old server running 18.04 gives this output

Sun Nov 10 17:16:16 AEDT 2019

Note the difference in both the time given and the format.

Can someone advise me where the default format for date output is configured. I can't see anything in the environment variables.

Note that timedatectl for both give similar results, the only difference being that 18.04 is using systemd-timesyncd and 19.10 is using NTP.

18.04

Local time: Sun 2019-11-10 17:16:18 AEDT Universal time: Sun 2019-11-10 06:16:18 UTC RTC time: Sun 2019-11-10 06:16:18 Time zone: Australia/Melbourne (AEDT, +1100) System clock synchronized: yes systemd-timesyncd.service active: yes RTC in local TZ: no

19.10

Local time: Sun 2019-11-10 17:16:12 AEDT Universal time: Sun 2019-11-10 06:16:12 UTC RTC time: Sun 2019-11-10 06:16:12 Time zone: Australia/Melbourne (AEDT, +1100) System clock synchronized: yes NTP service: active RTC in local TZ: no

  • The format of the date output should come from /usr/share/i18n/locales/[your location] (for [your location] check echo $LC_TIME or echo $LANG). I guess date_fmt is what you are searching for. But before changing any system generated file (locale-gen), I suggest to use LC_TIME=en_AU.UTF-8 date or LC_TIME=POSIX date ... Details on 'locale': pubs.opengroup.org/onlinepubs/009695399/basedefs/… – LupusE Nov 10 '19 at 9:25
  • Thanks @LupusE. $LC_TIME is not set on either servers but $LANG is set to en_US so that will need to change to en_AU. Further to that, the locale file en_US does not have a date_fmt setting on V18.04 but is date_fmt "%a %d %b %Y %r %Z" on V19.10. Looking at en_AU, both versions have date_fmt "%a %e %b %H:%M:%S %Z %Y" – dBags Nov 11 '19 at 19:29
1

The difference in format appears to be (not tested) caused by /usr/share/i18n/locales/en_US having date_fmt set in version 19.10 but not in 18.04. To fix (avoid) the problem, I changed my locale to en_AU.UTF-8. sudo vi /etc/locale.gen and uncommented en_AU.UTF-8. sudo locale-gen sudo update-locale LANG=en_AU.UTF-8 exit I did this on both servers and they now report the date in the same format.

| improve this answer | |
  • Out of curiosity, I set both servers back to en_US.UTF-8 and both are now report the date in the same format. I am guessing running locale.gen updated something. An observation is date_fmt is the same on both but d_t_fmt is different. – dBags Nov 11 '19 at 21:00

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.