Bash: Display Current Date

How do I display the current date under Bash UNIX / Linux / OS X shell?

Use the date command to dispkay or set system date and time. Invoking date command with no FORMAT argument is equivalent to invoking it with a default format that depends on the LC_TIME locale category. Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following command:
$ date
Sample outputs:

ADVERTISEMENTS

Tue Dec  7 03:08:34 IST 2010

To display the date of the day before yesterday, enter:
$ date --date='2 days ago'
To display the date of the day three months and one day, enter:
$ date --date='3 months 1 day'
To display the current full month name and the day of the month:
$ date '+%B %d'
Anytime you need assistance with date command, turn to the man or info pages first. They give you detailed information, parameters and switches for date command. Just type man followed by the name of the command (i.e. date) to open the appropriate man page. For example, man date opens the man page for the date command:
$ man date
OR (may not work on OS X and other UNIX like systems)
$ info date

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
Network Utilitiesdig host ip nmap
Package Managerapk apt
Processes Managementbg chroot disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w

ADVERTISEMENTS
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.