'w' use 24h

'w' command returns time in 12h format, how can this be changed to use the 24h format? It is the same in sh, csh, bash and zsh
Code:
% w
3:33PM  up 41 days, 21:38, 2 users, load averages: 0.00, 0.02, 0.07
USER       TTY      FROM          LOGIN@  IDLE WHAT
sparkee   pts/0    192.71.118.85   3:03PM     - w
 
For me it uses 24h format.
I have set
Code:
setenv LC_ALL de_DE.UTF-8
setenv LANG de_DE.UTF-8
so maybe you need to set a correct locale?
 
Well it seems I have too much time at the moment so I got curious...

My systems also show am/pm format for "w". Command "who" seems correct.
Normally i use :
Code:
$ locale
LANG=C.UTF-8
LC_CTYPE="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_TIME="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_ALL=

Så I changed locale to LANG=de_DE.UTF-8
and w then return 24h format.

Ok set locale to Danish:
Code:
export LANG=da_DK.UTF-8
locale
ANG=da_DK.UTF-8
LC_CTYPE="da_DK.UTF-8"
LC_COLLATE="da_DK.UTF-8"
LC_TIME="da_DK.UTF-8"
LC_NUMERIC="da_DK.UTF-8"
LC_MONETARY="da_DK.UTF-8"
LC_MESSAGES="da_DK.UTF-8"

w still uses am/pm format - weird, should have been 24h.

Looking at:
Code:
locale -k | grep am_pm
am_pm="AM;PM"

Ok - thats wrong.

Changing locale to German:
Code:
export LANG=de_DE.UTF-8
locale -k | grep am_pm
am_pm=";"
So now we are getting somewhere, the am_pm keyword is different!


Code:
cd /usr/share/locale/da_DK.UTF-8
vi LC_TIME

find the two lines AM and PM and setting both to ""

export LANG=da_DK.UTF-8

heureka! "w" now displays 24h format.


Sounds like a PR is required.


So check your locale is set correct.
see if the keyword "am_pm" is correct and change /usr/share/local/<LANG_env> accordingly.
 
Back
Top