If I run the date
command from the terminal, I get output like the following:
$ date
Fri Jan 22 13:45:44 CST 2021
If I want to format the date output different, perhaps for inclusion in a shell script, I can do something like this:
$ date +"%Y/%m/%d %H:%M:%S"
2021/01/22 13:47:55
Then I can incorporate that in a script like this:
now() {
echo "Today: $(date +'%Y/%m/%d %H:%M:%S')"
}
This page includes some examples and a page of formatting options.