Format Current Date in Shell Script (Bash)

August 22, 2018

Year, Month, Date (e.g. 20180120).

timestamp=`date +"%Y%m%d"`

Date + Time (e.g. 2018-01-20 22:10:05)

timestamp=`date '+%Y-%m-%d %H:%M:%S

NOTE: Check date format.

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.