The date command has several options for formatting the output. Here are some commonly used options:
-
Display the current time:
date +%TOutput:
14:30:00(HH:MM:SS format) -
Display the full date and time:
date +"%Y-%m-%d %H:%M:%S"Output:
2023-10-20 14:30:00 -
Display the day of the week:
date +%AOutput:
Friday -
Display the month name:
date +%BOutput:
October -
Display the Unix timestamp:
date +%sOutput:
1697815800(number of seconds since Jan 1, 1970) -
Custom format:
You can combine format specifiers. For example:date +"Today is %A, %B %d, %Y"Output:
Today is Friday, October 20, 2023
For a complete list of options, you can check the manual page by running:
man date
Let me know if you need more information!
