The date
command in Bash is used to display the current date and time in various formats. It can also be used to set the system date and time, although this typically requires administrative privileges.
The basic syntax of the date
command is as follows:
date [options] [arguments]
+FORMAT
: Format the output according to the specified format string.-u
: Display the date in Coordinated Universal Time (UTC).-d STRING
: Display the date corresponding to the STRING instead of the current date.-R
: Output the date in RFC 2822 format.date
date "+%Y-%m-%d %H:%M:%S"
date -u
date -d "2023-10-01"
date -R
+FORMAT
option to customize the output to suit your needs, such as including only the year, month, or day.man date
command in your terminal.date
command for setting the date.