How do I tell the `date` command to only show the time?

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?


Solution 1:

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.

Solution 2:

Current time 24h format:

date +%R

Current time 12h format with AM/PM:

date +%I:%M%p

Solution 3:

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

Solution 4:

I use this:

date +%T

for nanoseconds use this:

date +%T.%N

Example outputs:

vlad@vlcomp:~$ date +%T
19:23:34
vlad@vlcomp:~$ date +%T.%N
19:23:38.780062589
vlad@vlcomp:~$