How can I get the current date and time in the terminal and set a custom command in the terminal for it?

harshal picture harshal · Aug 27, 2013 · Viewed 1.4M times · Source

I have to check the time in a Linux terminal.

What is the command for getting date and time in a Linux terminal?

Is there a way in which we can set a custom function?

Answer

Vorsprung picture Vorsprung · Aug 27, 2013

The command is date

To customise the output there are a myriad of options available, see date --help for a list.

For example, date '+%A %W %Y %X' gives Tuesday 34 2013 08:04:22 which is the name of the day of the week, the week number, the year and the time.