Search code examples
linuxposixlocale

How to get year from POSIX date


Mu current Locale is POSIX.

Output of command :

$ locale | grep LC_TIME 

LC_TIME=POSIX

$who -b

system boot  Jul 31 11:08

I just want to get system boot year.

is there any way to get. Thanks


Solution

  • who -b | awk '{$1=""; $2=""; print $0}' | date -f -

    Or if you only want the year:

    who -b | awk '{$1=""; $2=""; print $0}' | date -f - +%Y