I am trying to display only the current time using "date", not all that information Day, Month, Year etc.. , only the current time.
i.e.:
13:45 or 1:45pm
Any ideas?
I am trying to display only the current time using "date", not all that information Day, Month, Year etc.. , only the current time.
i.e.:
13:45 or 1:45pm
Any ideas?
date +%R
will show you the 24 hour time, and
date +%r
will show you the time in 12 hour format. date +%H:%I
also works.
Check out the "Conversion Specifications" in the manpage for more variables to pick and choose.
%R
is like %H:%M
, %r
is like %I:%M:%S
. So the 12h version of %R
is %I:%M%p
. %H:%I
instead looks wrong to me (it gives you hour in 24h and hour in 12h).
Current time 24h format:
date +%R
Current time 12h format with AM/PM:
date +%I:%M%p
date +%H:%M
for 13:45
date +%H:%M #(if you don't write these : it is shown as for exmp. 0145)
for 01:45
"uptime"
will tell how long the system has been running (along with other information) check man entry for uptime
I use this:
date +%T
for nanoseconds use this:
date +%T.%N
Example outputs:
$ date +%T
19:23:34
$ date +%T.%N
19:23:38.780062589
last
displays info about recent logins. See http://linux.about.com/library/cmd/blcmdl1_last.htm for more info about it. I think it can show shutdowns too. For the time try date +%r
. See http://linux.about.com/od/commands/l/blcmdl1_date.htm for more info on date.