runtime=$(date +\%Y\%m\%d\%H\%M\%S) code example
Example 1: runtime=$(date +\%Y\%m\%d\%H\%M\%S)
# Found at https://zxq9.com/archives/795
#
cat << EOD
Format/result | Command | Output
--------------------------------+----------------------------+------------------------------
YYYY-MM-DD | date -I | $(date -I)
YYYY-MM-DD_hh:mm:ss | date +%F_%T | $(date +%F_%T)
YYYYMMDD_hhmmss | date +%Y%m%d_%H%M%S | $(date +%Y%m%d_%H%M%S)
YYYYMMDD_hhmmss (UTC version) | date --utc +%Y%m%d_%H%M%SZ | $(date --utc +%Y%m%d_%H%M%SZ)
YYYYMMDD_hhmmss (with local TZ) | date +%Y%m%d_%H%M%S%Z | $(date +%Y%m%d_%H%M%S%Z)
YYYYMMSShhmmss | date +%Y%m%d%H%M%S | $(date +%Y%m%d%H%M%S)
YYYYMMSShhmmssnnnnnnnnn | date +%Y%m%d%H%M%S%N | $(date +%Y%m%d%H%M%S%N)
YYMMDD_hhmmss | date +%y%m%d_%H%M%S | $(date +%y%m%d_%H%M%S)
Seconds since UNIX epoch: | date +%s | $(date +%s)
Nanoseconds only: | date +%N | $(date +%N)
Nanoseconds since UNIX epoch: | date +%s%N | $(date +%s%N)
ISO8601 UTC timestamp | date --utc +%FT%TZ | $(date --utc +%FT%TZ)
ISO8601 UTC timestamp + ms | date --utc +%FT%T.%3NZ | $(date --utc +%FT%T.%3NZ)
ISO8601 Local TZ timestamp | date +%FT%T%Z | $(date +%FT%T%Z)
YYYY-MM-DD (Short day) | date +%F\(%a\) | $(date +%F\(%a\))
YYYY-MM-DD (Long day) | date +%F\(%A\) | $(date +%F\(%A\))
EOD
Example 2: runtime=$(date +\%Y\%m\%d\%H\%M\%S)
# -d date arithmetic
# Display the time described by the user friendly string, not by now.
date -d "+5 days"
date -d "+7 weeks +2 days"
date -d "last Wednesday 2 pm"
Example 3: runtime=$(date +\%Y\%m\%d\%H\%M\%S)
# Time Zones
# Some z and z specifiers show the current active time zone
echo $(date '+%z' ) # +0200
echo $(date '+%:z' ) # +02:00
echo $(date '+%::z' ) # +02:00:00
echo $(date '+%:::z') # +02 (Print required precision only)
echo $(date '+%Z' ) # CEST (Alphabetic timezone abbreviation)