sh current datetime code example
Example 1: bash get current date
# syntax
$(date)
# example (when running the command of "date")
echo $(date)
# OUTPUT: Mon May 11 13:20:57 SAST 2020
# To return a specific FORMAT, search "bash get date format"
Example 2: current year bash
date +"%Y"
date +"%y"
## Store to a shell variable ##
mydate=$(date +'%Y')
myyear=`date +'%Y'`
echo "Year = $mydate"
echo "Year = $myyear"